Changed type of exception from CastClassException to TypeCastException
When converting from null to non-nullable type kotlin JVM throws TypeCastException
This commit is contained in:
+3
-3
@@ -52,8 +52,8 @@ private class TypeOperatorTransformer(val context: Context, val function: Functi
|
||||
|
||||
private val builder = context.createIrBuilder(function)
|
||||
|
||||
val throwClassCastException by lazy {
|
||||
context.builtIns.getKonanInternalFunctions("ThrowClassCastException").single()
|
||||
val throwTypeCastException by lazy {
|
||||
context.builtIns.getKonanInternalFunctions("ThrowTypeCastException").single()
|
||||
}
|
||||
|
||||
override fun visitFunction(declaration: IrFunction): IrStatement {
|
||||
@@ -101,7 +101,7 @@ private class TypeOperatorTransformer(val context: Context, val function: Functi
|
||||
thenPart = if (typeOperand.isMarkedNullable)
|
||||
irNull()
|
||||
else
|
||||
irCall(throwClassCastException),
|
||||
irCall(throwTypeCastException),
|
||||
|
||||
elsePart = irAs(irGet(argument), typeOperand.makeNotNullable())
|
||||
)
|
||||
|
||||
@@ -31,6 +31,10 @@ fun ThrowClassCastException(): Nothing {
|
||||
throw ClassCastException()
|
||||
}
|
||||
|
||||
fun ThrowTypeCastException(): Nothing {
|
||||
throw TypeCastException()
|
||||
}
|
||||
|
||||
@ExportForCppRuntime
|
||||
internal fun ThrowArithmeticException() : Nothing {
|
||||
throw ArithmeticException()
|
||||
|
||||
Reference in New Issue
Block a user