mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 00:21:26 +00:00
Generate proper initialization for possibly nullable SAM wrapper
#KT-18916 Fixed Target versions 1.1.5
This commit is contained in:
26
compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt
vendored
Normal file
26
compiler/testData/codegen/bytecodeText/sam/samWrapperForNullInitialization.kt
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: JFoo.java
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JFoo {
|
||||
public static void foo2(@Nullable Runnable h1, @Nullable Runnable h2) {
|
||||
if (h2 != null) throw new AssertionError();
|
||||
h1.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Test.kt
|
||||
fun test() {
|
||||
var i = 0
|
||||
JFoo.foo2({ i++ }, null)
|
||||
}
|
||||
|
||||
// @TestKt.class:
|
||||
// 1 NEW TestKt\$test\$1
|
||||
// 1 NEW kotlin/jvm/internal/Ref\$IntRef
|
||||
// 2 NEW
|
||||
// 1 INVOKESPECIAL TestKt\$test\$1.<init>
|
||||
// 0 IFNONNULL
|
||||
// 0 IFNULL
|
||||
// 1 ACONST_NULL
|
||||
24
compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt
vendored
Normal file
24
compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
// WITH_RUNTIME
|
||||
// FILE: JFoo.java
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class JFoo {
|
||||
public static void foo2(@Nullable Runnable h1, @Nullable Runnable h2) {
|
||||
if (h2 != null) throw new AssertionError();
|
||||
h1.run();
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Test.kt
|
||||
fun runnable(): (() -> Unit)? = null
|
||||
|
||||
fun test() {
|
||||
JFoo.foo2({}, runnable())
|
||||
}
|
||||
|
||||
// @TestKt.class:
|
||||
// 2 NEW
|
||||
// 0 IFNONNULL
|
||||
// 1 IFNULL
|
||||
// 1 ACONST_NULL
|
||||
Reference in New Issue
Block a user