diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java index bab08db40f4..1a52e307277 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/AsmUtil.java @@ -341,7 +341,7 @@ public class AsmUtil { } if (memberDescriptor instanceof ConstructorDescriptor && isAnonymousObject(memberDescriptor.getContainingDeclaration())) { - return NO_FLAG_PACKAGE_PRIVATE; + return getVisibilityAccessFlagForAnonymous((ClassDescriptor) memberDescriptor.getContainingDeclaration()); } if (memberDescriptor instanceof SyntheticJavaPropertyDescriptor) { diff --git a/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.1.kt b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.1.kt new file mode 100644 index 00000000000..f2f653f5979 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.1.kt @@ -0,0 +1,5 @@ +import test.* + +fun box(): String { + return A().doSomething().run() +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.2.kt b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.2.kt new file mode 100644 index 00000000000..c5466e64c06 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.2.kt @@ -0,0 +1,13 @@ +package test + +interface Run { + fun run(): String +} + +internal class A { + inline fun doSomething(): Run { + return object : Run { + override fun run(): String = "OK" + } + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInConstLambda.1.kt b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInConstLambda.1.kt new file mode 100644 index 00000000000..298fe8f789b --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInConstLambda.1.kt @@ -0,0 +1,5 @@ +import test.* + +fun box(): String { + return A().doSomething() +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInConstLambda.2.kt b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInConstLambda.2.kt new file mode 100644 index 00000000000..b8ed17cf74c --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInConstLambda.2.kt @@ -0,0 +1,9 @@ +package test + +internal class A { + inline fun doSomething(): String { + return { + "OK" + }() + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInLambda.1.kt b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInLambda.1.kt new file mode 100644 index 00000000000..7053160d548 --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInLambda.1.kt @@ -0,0 +1,5 @@ +import test.* + +fun box(): String { + return A().doSomething("OK") +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInLambda.2.kt b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInLambda.2.kt new file mode 100644 index 00000000000..996944b8d4b --- /dev/null +++ b/compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInLambda.2.kt @@ -0,0 +1,9 @@ +package test + +internal class A { + inline fun doSomething(s: String): String { + return { + s + }() + } +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java index 42b0b9c4b31..b373f23792c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxInlineCodegenTestGenerated.java @@ -97,6 +97,24 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo doTestMultiFileWithInlineCheck(fileName); } + @TestMetadata("constructorVisibility.1.kt") + public void testConstructorVisibility() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("constructorVisibilityInConstLambda.1.kt") + public void testConstructorVisibilityInConstLambda() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInConstLambda.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + + @TestMetadata("constructorVisibilityInLambda.1.kt") + public void testConstructorVisibilityInLambda() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInLambda.1.kt"); + doTestMultiFileWithInlineCheck(fileName); + } + @TestMetadata("kt8133.1.kt") public void testKt8133() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt8133.1.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java index c4c125248c2..f51b3b688ee 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -97,6 +97,24 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi doBoxTestWithInlineCheck(fileName); } + @TestMetadata("constructorVisibility.1.kt") + public void testConstructorVisibility() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibility.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("constructorVisibilityInConstLambda.1.kt") + public void testConstructorVisibilityInConstLambda() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInConstLambda.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + + @TestMetadata("constructorVisibilityInLambda.1.kt") + public void testConstructorVisibilityInLambda() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/constructorVisibilityInLambda.1.kt"); + doBoxTestWithInlineCheck(fileName); + } + @TestMetadata("kt8133.1.kt") public void testKt8133() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/anonymousObject/kt8133.1.kt");