Verbose ClassCastException
This commit is contained in:
committed by
Sergey Bogolepov
parent
cd4f116f78
commit
6184685111
@@ -39,7 +39,7 @@ void RUNTIME_NORETURN ThrowNullPointerException();
|
|||||||
// Context is evaluated from caller's address.
|
// Context is evaluated from caller's address.
|
||||||
void RUNTIME_NORETURN ThrowArrayIndexOutOfBoundsException();
|
void RUNTIME_NORETURN ThrowArrayIndexOutOfBoundsException();
|
||||||
// Throws class cast exception.
|
// Throws class cast exception.
|
||||||
void RUNTIME_NORETURN ThrowClassCastException();
|
void RUNTIME_NORETURN ThrowClassCastException(const ObjHeader* instance, const TypeInfo* type_info);
|
||||||
// Throws arithmetic exception.
|
// Throws arithmetic exception.
|
||||||
void RUNTIME_NORETURN ThrowArithmeticException();
|
void RUNTIME_NORETURN ThrowArithmeticException();
|
||||||
// Throws number format exception.
|
// Throws number format exception.
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ void CheckInstance(const ObjHeader* obj, const TypeInfo* type_info) {
|
|||||||
if (IsInstance(obj, type_info)) {
|
if (IsInstance(obj, type_info)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ThrowClassCastException();
|
ThrowClassCastException(obj, type_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
KBoolean Kotlin_TypeInfo_isInstance(KConstRef obj, KNativePtr typeInfo) {
|
KBoolean Kotlin_TypeInfo_isInstance(KConstRef obj, KNativePtr typeInfo) {
|
||||||
|
|||||||
@@ -30,8 +30,9 @@ internal fun ThrowArrayIndexOutOfBoundsException(): Nothing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ExportForCppRuntime
|
@ExportForCppRuntime
|
||||||
fun ThrowClassCastException(): Nothing {
|
fun ThrowClassCastException(instance: Any, typeInfo: NativePtr): Nothing {
|
||||||
throw ClassCastException()
|
val clazz = KClassImpl<Any>(typeInfo)
|
||||||
|
throw ClassCastException("${instance::class.qualifiedName} cannot be cast to ${clazz.qualifiedName}")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ThrowTypeCastException(): Nothing {
|
fun ThrowTypeCastException(): Nothing {
|
||||||
|
|||||||
Reference in New Issue
Block a user