diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java index fe7cfd62b81..6271554f57a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/AnonymousObjectTransformer.java @@ -271,7 +271,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY + NO_ORIGIN, constructor.access, "", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY ); final Label newBodyStartLabel = new Label(); @@ -312,7 +312,7 @@ public class AnonymousObjectTransformer extends ObjectTransformer", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY); + new MethodNode(constructor.access, "", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY); inlineMethodAndUpdateGlobalResult(parentRemapper, intermediateMethodNode, constructor, constructorInlineBuilder, true); InlineCodegenUtil.removeFinallyMarkers(intermediateMethodNode); diff --git a/compiler/testData/codegen/boxInline/anonymousObject/kt16193.kt b/compiler/testData/codegen/boxInline/anonymousObject/kt16193.kt new file mode 100644 index 00000000000..1e7682f6894 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/kt16193.kt @@ -0,0 +1,29 @@ +//WITH_RUNTIME +//FULL_JDK +// FILE: 1.kt +package test + +inline fun crashMe(crossinline callback: () -> Unit): Function0 { + return object: Function0 { + override fun invoke() { + callback() + } + } +} + +// FILE: 2.kt + +import test.* +import java.lang.reflect.Modifier + +var result = "fail" + + +fun box(): String { + val crashMe = crashMe { result = "OK" } + val modifiers = crashMe::class.java.getDeclaredConstructor().modifiers + if (!Modifier.isPublic(modifiers)) return "fail $modifiers" + + crashMe.invoke() + return result +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 9fb3350f48f..6ef76ae1428 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -158,6 +158,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo doTest(fileName); } + @TestMetadata("kt16193.kt") + public void testKt16193() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt16193.kt"); + doTest(fileName); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 2713856eb17..33ece1745e6 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -158,6 +158,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi doTest(fileName); } + @TestMetadata("kt16193.kt") + public void testKt16193() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt16193.kt"); + doTest(fileName); + } + @TestMetadata("kt6552.kt") public void testKt6552() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt6552.kt");