JVM_IR make $deserializeLambda$ method synthetic
This commit is contained in:
committed by
teamcityserver
parent
1dbbe22c8c
commit
6e9cbf52b1
+1
@@ -264,6 +264,7 @@ private class TypeOperatorLowering(private val context: JvmBackendContext) : Fil
|
||||
val deserializeLambdaFun = context.irFactory.buildFun {
|
||||
name = Name.identifier("\$deserializeLambda\$")
|
||||
visibility = DescriptorVisibilities.PRIVATE
|
||||
origin = JvmLoweredDeclarationOrigin.DESERIALIZE_LAMBDA_FUN
|
||||
}
|
||||
deserializeLambdaFun.parent = irClass
|
||||
val lambdaParameter = deserializeLambdaFun.addValueParameter("lambda", context.ir.symbols.serializedLambda.irType)
|
||||
|
||||
+1
@@ -50,4 +50,5 @@ interface JvmLoweredDeclarationOrigin : IrDeclarationOrigin {
|
||||
object INLINE_LAMBDA : IrDeclarationOriginImpl("INLINE_LAMBDA")
|
||||
object PROXY_FUN_FOR_METAFACTORY : IrDeclarationOriginImpl("PROXY_FUN_FOR_METAFACTORY")
|
||||
object SYNTHETIC_PROXY_FUN_FOR_METAFACTORY : IrDeclarationOriginImpl("SYNTHETIC_PROXY_FUN_FOR_METAFACTORY", isSynthetic = true)
|
||||
object DESERIALIZE_LAMBDA_FUN : IrDeclarationOriginImpl("DESERIALIZE_LAMBDA_FUN", isSynthetic = true)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
// FILE: deserializeLambdaMethod.kt
|
||||
|
||||
fun plusK(s: String) = s + "K"
|
||||
|
||||
// Creating a serializable lambda causes '$deserializeLambda$' method to be generated in the corresponding class.
|
||||
// Given equivalent code, javac generates
|
||||
// private static synthetic $deserializeLambda$(Ljava/lang/invoke/SerializedLambda;)Ljava/lang/Object;
|
||||
val test = Sam(::plusK)
|
||||
|
||||
// FILE: Sam.java
|
||||
import java.io.*;
|
||||
|
||||
public interface Sam extends Serializable {
|
||||
String get(String s);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
@kotlin.Metadata
|
||||
public final class DeserializeLambdaMethodKt {
|
||||
// source: 'deserializeLambdaMethod.kt'
|
||||
private final static @org.jetbrains.annotations.NotNull field test: Sam
|
||||
private synthetic final static method $deserializeLambda$(p0: java.lang.invoke.SerializedLambda): java.lang.Object
|
||||
static method <clinit>(): void
|
||||
public final static @org.jetbrains.annotations.NotNull method getTest(): Sam
|
||||
public final static @org.jetbrains.annotations.NotNull method plusK(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
|
||||
}
|
||||
+6
@@ -97,6 +97,12 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/delegationToJavaInterfaceWithWildcardType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deserializeLambdaMethod.kt")
|
||||
public void testDeserializeLambdaMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/deserializeLambdaMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
|
||||
+6
@@ -97,6 +97,12 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes
|
||||
runTest("compiler/testData/codegen/bytecodeListing/delegationToJavaInterfaceWithWildcardType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("deserializeLambdaMethod.kt")
|
||||
public void testDeserializeLambdaMethod() throws Exception {
|
||||
runTest("compiler/testData/codegen/bytecodeListing/deserializeLambdaMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("enum.kt")
|
||||
public void testEnum() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user