JVM IR: Generate synthetic final implementation methods in SAM wrappers

This commit is contained in:
Steven Schäfer
2020-10-28 18:00:44 +01:00
committed by Alexander Udalov
parent a475fa2a21
commit 68e2d0d245
5 changed files with 38 additions and 1 deletions
@@ -4353,6 +4353,11 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest {
public void testSamWrapperSyntheticFlags() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticFlags.kt");
}
@TestMetadata("samWrapperSyntheticImplementationMethod.kt")
public void testSamWrapperSyntheticImplementationMethod() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticImplementationMethod.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
@@ -209,7 +209,8 @@ abstract class SingleAbstractMethodLowering(val context: CommonBackendContext) :
name = superMethod.name
returnType = superMethod.returnType
visibility = superMethod.visibility
origin = subclass.origin
modality = Modality.FINAL
origin = IrDeclarationOrigin.SYNTHETIC_GENERATED_SAM_IMPLEMENTATION
isSuspend = superMethod.isSuspend
setSourceRange(createFor)
}.apply {
@@ -0,0 +1,21 @@
// FILE: J.java
public class J {
public static void g(Runnable r) {
r.run();
}
}
// FILE: test.kt
fun nonInlineFun() {
val f = {}
J.g(f)
}
inline fun inlineFun() {
val f = {}
J.g(f)
}
// 2 public final synthetic run\(\)V
@@ -4425,6 +4425,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest {
public void testSamWrapperSyntheticFlags() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticFlags.kt");
}
@TestMetadata("samWrapperSyntheticImplementationMethod.kt")
public void testSamWrapperSyntheticImplementationMethod() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticImplementationMethod.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")
@@ -4353,6 +4353,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest {
public void testSamWrapperSyntheticFlags() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticFlags.kt");
}
@TestMetadata("samWrapperSyntheticImplementationMethod.kt")
public void testSamWrapperSyntheticImplementationMethod() throws Exception {
runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticImplementationMethod.kt");
}
}
@TestMetadata("compiler/testData/codegen/bytecodeText/statements")