Add tests for merging SAM wrappers and references
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
// FILE: JFoo.java
|
||||||
|
|
||||||
|
public class JFoo {
|
||||||
|
public static void foo(Runnable f) {
|
||||||
|
f.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.kt
|
||||||
|
fun test() {
|
||||||
|
JFoo.foo({})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lambda inlined into run(), no wrapper class generated:
|
||||||
|
// 1 NEW
|
||||||
|
// 0 INVOKEINTERFACE
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// This optimization is only done by the JVM_IR backend.
|
||||||
|
// IGNORE_BACKEND: JVM
|
||||||
|
// FILE: JFoo.java
|
||||||
|
|
||||||
|
public class JFoo {
|
||||||
|
public static void foo(Runnable f) {
|
||||||
|
f.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Test.kt
|
||||||
|
class A {
|
||||||
|
fun f() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
JFoo.foo(A()::f)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Referenced function called from run(), no wrapper class generated:
|
||||||
|
// 1 NEW A
|
||||||
|
// 2 NEW
|
||||||
|
// 0 INVOKEINTERFACE
|
||||||
@@ -3264,6 +3264,16 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
|
|||||||
public void testSamWrapperForNullableInitialization() throws Exception {
|
public void testSamWrapperForNullableInitialization() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt");
|
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("samWrapperOfLambda.kt")
|
||||||
|
public void testSamWrapperOfLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("samWrapperOfReference.kt")
|
||||||
|
public void testSamWrapperOfReference() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperOfReference.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
|
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
|
||||||
|
|||||||
+10
@@ -3274,6 +3274,16 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
|
|||||||
public void testSamWrapperForNullableInitialization() throws Exception {
|
public void testSamWrapperForNullableInitialization() throws Exception {
|
||||||
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt");
|
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperForNullableInitialization.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("samWrapperOfLambda.kt")
|
||||||
|
public void testSamWrapperOfLambda() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperOfLambda.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("samWrapperOfReference.kt")
|
||||||
|
public void testSamWrapperOfReference() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperOfReference.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
|
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
|
||||||
|
|||||||
Reference in New Issue
Block a user