From f2e0c1a9303aed6b4acff9b6de88d9483436491d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steven=20Sch=C3=A4fer?= Date: Sat, 14 Sep 2019 00:11:00 +0200 Subject: [PATCH] JVM IR: Minor fix for nullable SAM wrappers --- .../backend/jvm/lower/SingleAbstractMethodLowering.kt | 2 +- .../sam/samWrapperForNullableInitialization.kt | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingleAbstractMethodLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingleAbstractMethodLowering.kt index 9c0da7bf659..92ca84fed5b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingleAbstractMethodLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SingleAbstractMethodLowering.kt @@ -92,7 +92,7 @@ class SingleAbstractMethodLowering(val context: CommonBackendContext) : FileLowe val instance = irCall(implementation.constructors.single()).apply { putValueArgument(0, irGet(invokableVariable)) } - irIfNull(superType, irGet(invokableVariable), irNull(), instance) + +irIfNull(superType, irGet(invokableVariable), irNull(), instance) } } else { irCall(implementation.constructors.single()).apply { putValueArgument(0, invokable) } diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt index ec4e4f53af9..757821e3886 100644 --- a/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND: JVM_IR // FILE: JFoo.java import org.jetbrains.annotations.Nullable; @@ -17,8 +16,16 @@ fun test() { JFoo.foo2({}, runnable()) } -// @TestKt.class: // 2 NEW + +// JVM_TEMPLATES +// @TestKt.class: // 0 IFNONNULL // 1 IFNULL // 1 ACONST_NULL + +// JVM_IR_TEMPLATES +// @TestKt.class +// 1 IFNONNULL +// 0 IFNULL +// 2 ACONST_NULL