From b15875cc1556f7dc7be43311e8ee537c8dd5ec4e Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Thu, 30 Jan 2020 15:45:19 +0300 Subject: [PATCH] [IR] Throw NPE instead of KCE on attempt to cast from null --- .../kotlin/backend/konan/lower/TypeOperatorLowering.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt index e95a6f6f0cb..d9d779c8864 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/TypeOperatorLowering.kt @@ -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()) )