[IR] Throw NPE instead of KCE on attempt to cast from null

This commit is contained in:
Igor Chevdar
2020-01-30 15:45:19 +03:00
parent d6df4f8b21
commit b15875cc15
@@ -47,7 +47,7 @@ private class TypeOperatorTransformer(val context: CommonBackendContext, val fun
private val builder = context.createIrBuilder(function)
val throwTypeCastException = context.ir.symbols.ThrowTypeCastException
val throwNullPointerException = context.ir.symbols.ThrowNullPointerException
override fun visitFunction(declaration: IrFunction): IrStatement {
// ignore inner functions during this pass
@@ -96,7 +96,7 @@ private class TypeOperatorTransformer(val context: CommonBackendContext, val fun
thenPart = if (typeOperand.isSimpleTypeWithQuestionMark)
irNull()
else
irCall(throwTypeCastException.owner),
irCall(throwNullPointerException.owner),
elsePart = irAs(irGet(argument.owner), typeOperand.makeNotNull())
)