[IR] Throw NPE instead of KCE on attempt to cast from null
This commit is contained in:
+2
-2
@@ -47,7 +47,7 @@ private class TypeOperatorTransformer(val context: CommonBackendContext, val fun
|
|||||||
|
|
||||||
private val builder = context.createIrBuilder(function)
|
private val builder = context.createIrBuilder(function)
|
||||||
|
|
||||||
val throwTypeCastException = context.ir.symbols.ThrowTypeCastException
|
val throwNullPointerException = context.ir.symbols.ThrowNullPointerException
|
||||||
|
|
||||||
override fun visitFunction(declaration: IrFunction): IrStatement {
|
override fun visitFunction(declaration: IrFunction): IrStatement {
|
||||||
// ignore inner functions during this pass
|
// ignore inner functions during this pass
|
||||||
@@ -96,7 +96,7 @@ private class TypeOperatorTransformer(val context: CommonBackendContext, val fun
|
|||||||
thenPart = if (typeOperand.isSimpleTypeWithQuestionMark)
|
thenPart = if (typeOperand.isSimpleTypeWithQuestionMark)
|
||||||
irNull()
|
irNull()
|
||||||
else
|
else
|
||||||
irCall(throwTypeCastException.owner),
|
irCall(throwNullPointerException.owner),
|
||||||
|
|
||||||
elsePart = irAs(irGet(argument.owner), typeOperand.makeNotNull())
|
elsePart = irAs(irGet(argument.owner), typeOperand.makeNotNull())
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user