diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BuiltinOperatorLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BuiltinOperatorLowering.kt index c8b56c60c5c..369c9968f81 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BuiltinOperatorLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/BuiltinOperatorLowering.kt @@ -184,7 +184,7 @@ internal class BuiltinOperatorLowering(val context: Context) : FileLoweringPass, } } - private fun lowerCheckNotNull(expression: IrCall) = builder.at(expression).irBlock { + private fun lowerCheckNotNull(expression: IrCall) = builder.at(expression).irBlock(resultType = expression.type) { val temp = irTemporary(expression.getValueArgument(0)!!) +irIfThen(context.irBuiltIns.unitType, irEqeqNull(irGet(temp)), irCall(symbols.ThrowNullPointerException)) +irGet(temp) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt index 6aa3e1ed6ec..40ae38c1424 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt @@ -152,7 +152,7 @@ fun IrBuilderWithScope.irForceNotNull(expression: IrExpression): IrExpression { return expression } - return irCall(context.irBuiltIns.checkNotNullSymbol).apply { + return irCall(context.irBuiltIns.checkNotNullSymbol, expression.type.makeNotNull()).apply { putValueArgument(0, expression) } }