Verbose ClassCastException

This commit is contained in:
Sergey Bogolepov
2018-08-09 14:27:08 +03:00
committed by Sergey Bogolepov
parent cd4f116f78
commit 6184685111
3 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ void RUNTIME_NORETURN ThrowNullPointerException();
// Context is evaluated from caller's address.
void RUNTIME_NORETURN ThrowArrayIndexOutOfBoundsException();
// Throws class cast exception.
void RUNTIME_NORETURN ThrowClassCastException();
void RUNTIME_NORETURN ThrowClassCastException(const ObjHeader* instance, const TypeInfo* type_info);
// Throws arithmetic exception.
void RUNTIME_NORETURN ThrowArithmeticException();
// Throws number format exception.
+1 -1
View File
@@ -47,7 +47,7 @@ void CheckInstance(const ObjHeader* obj, const TypeInfo* type_info) {
if (IsInstance(obj, type_info)) {
return;
}
ThrowClassCastException();
ThrowClassCastException(obj, type_info);
}
KBoolean Kotlin_TypeInfo_isInstance(KConstRef obj, KNativePtr typeInfo) {
@@ -30,8 +30,9 @@ internal fun ThrowArrayIndexOutOfBoundsException(): Nothing {
}
@ExportForCppRuntime
fun ThrowClassCastException(): Nothing {
throw ClassCastException()
fun ThrowClassCastException(instance: Any, typeInfo: NativePtr): Nothing {
val clazz = KClassImpl<Any>(typeInfo)
throw ClassCastException("${instance::class.qualifiedName} cannot be cast to ${clazz.qualifiedName}")
}
fun ThrowTypeCastException(): Nothing {