diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBytecodeTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBytecodeTextTestGenerated.java index 1554b74bb1e..4ee44af01be 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBytecodeTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBytecodeTextTestGenerated.java @@ -4339,6 +4339,11 @@ public class FirBytecodeTextTestGenerated extends AbstractFirBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperOfReference.kt"); } + @TestMetadata("samWrapperPrivateFinalSyntheticField.kt") + public void testSamWrapperPrivateFinalSyntheticField() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperPrivateFinalSyntheticField.kt"); + } + @TestMetadata("samWrapperSyntheticFlags.kt") public void testSamWrapperSyntheticFlags() throws Exception { runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticFlags.kt"); diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SingleAbstractMethodLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SingleAbstractMethodLowering.kt index ed397e9c154..e61d67505f3 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SingleAbstractMethodLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/SingleAbstractMethodLowering.kt @@ -177,8 +177,9 @@ abstract class SingleAbstractMethodLowering(val context: CommonBackendContext) : val field = subclass.addField { name = Name.identifier(FUNCTION_FIELD_NAME) type = wrappedFunctionType - origin = subclass.origin + origin = IrDeclarationOrigin.SYNTHETIC_GENERATED_SAM_IMPLEMENTATION visibility = DescriptorVisibilities.PRIVATE + isFinal = true setSourceRange(createFor) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt index 019a779a5d3..eb52fd4f9da 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt @@ -69,6 +69,7 @@ interface IrDeclarationOrigin { object ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION : IrDeclarationOriginImpl("ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION") object GENERATED_SAM_IMPLEMENTATION : IrDeclarationOriginImpl("GENERATED_SAM_IMPLEMENTATION") + object SYNTHETIC_GENERATED_SAM_IMPLEMENTATION : IrDeclarationOriginImpl("SYNTHETIC_GENERATED_SAM_IMPLEMENTATION", isSynthetic = true) val isSynthetic: Boolean get() = false } diff --git a/compiler/testData/codegen/bytecodeText/sam/samWrapperPrivateFinalSyntheticField.kt b/compiler/testData/codegen/bytecodeText/sam/samWrapperPrivateFinalSyntheticField.kt new file mode 100644 index 00000000000..30d4f2130c7 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/sam/samWrapperPrivateFinalSyntheticField.kt @@ -0,0 +1,16 @@ +// FILE: J.java + +public class J { + public static void g(Runnable r) { + r.run(); + } +} + +// FILE: test.kt + +fun f() { + val r: () -> Unit = {} + J.g(r) +} + +// 1 private final synthetic Lkotlin/jvm/functions/Function0; function \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index f1976cc0f8b..67793556522 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -4411,6 +4411,11 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperOfReference.kt"); } + @TestMetadata("samWrapperPrivateFinalSyntheticField.kt") + public void testSamWrapperPrivateFinalSyntheticField() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperPrivateFinalSyntheticField.kt"); + } + @TestMetadata("samWrapperSyntheticFlags.kt") public void testSamWrapperSyntheticFlags() throws Exception { runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticFlags.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index bb531ea877b..8d1fdfaef6b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -4339,6 +4339,11 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperOfReference.kt"); } + @TestMetadata("samWrapperPrivateFinalSyntheticField.kt") + public void testSamWrapperPrivateFinalSyntheticField() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperPrivateFinalSyntheticField.kt"); + } + @TestMetadata("samWrapperSyntheticFlags.kt") public void testSamWrapperSyntheticFlags() throws Exception { runTest("compiler/testData/codegen/bytecodeText/sam/samWrapperSyntheticFlags.kt");