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:
Igor Chevdar
2017-03-29 19:15:31 +03:00
parent 9d64aa7153
commit 662abba4a7
2 changed files with 7 additions and 3 deletions
@@ -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()