diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt index df337c51e4a..d8f32cf7f36 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt @@ -244,7 +244,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) { if (CodegenBinding.canHaveOuter(state.bindingContext, classDescriptor)) return false - if (Visibilities.isPrivate(classDescriptor.visibility) || Visibilities.isPrivate(constructorDescriptor.visibility)) + if (Visibilities.isPrivate(constructorDescriptor.visibility)) return false if (constructorDescriptor.valueParameters.isEmpty()) return false diff --git a/compiler/testData/codegen/box/jvmOverloads/privateClass.kt b/compiler/testData/codegen/box/jvmOverloads/privateClass.kt new file mode 100644 index 00000000000..cb324957d9a --- /dev/null +++ b/compiler/testData/codegen/box/jvmOverloads/privateClass.kt @@ -0,0 +1,10 @@ +// IGNORE_BACKEND: JS + +// WITH_RUNTIME + +private data class C(val status: String = "OK") + +fun box(): String { + val c = (C::class.java.getConstructor().newInstance()) + return c.status +} diff --git a/compiler/testData/codegen/defaultArguments/reflection/privateClass.kt b/compiler/testData/codegen/defaultArguments/reflection/privateClass.kt index b4293146ab5..9d3155b38e5 100644 --- a/compiler/testData/codegen/defaultArguments/reflection/privateClass.kt +++ b/compiler/testData/codegen/defaultArguments/reflection/privateClass.kt @@ -1,4 +1,4 @@ private class Foo(val a: Int = 1) {} // CLASS: Foo -// HAS_DEFAULT_CONSTRUCTOR: false +// HAS_DEFAULT_CONSTRUCTOR: true diff --git a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 4b52c936822..47fab28c4b4 100644 --- a/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-ir-jvm/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -8615,6 +8615,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes doTest(fileName); } + @TestMetadata("privateClass.kt") + public void testPrivateClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmOverloads/privateClass.kt"); + doTest(fileName); + } + @TestMetadata("secondaryConstructor.kt") public void testSecondaryConstructor() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmOverloads/secondaryConstructor.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 1f6cccfaa4a..3a17caba346 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -8615,6 +8615,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("privateClass.kt") + public void testPrivateClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmOverloads/privateClass.kt"); + doTest(fileName); + } + @TestMetadata("secondaryConstructor.kt") public void testSecondaryConstructor() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmOverloads/secondaryConstructor.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 0829e1af053..8d1c8bcd24e 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -10421,6 +10421,18 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); } + @TestMetadata("privateClass.kt") + public void testPrivateClass() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmOverloads/privateClass.kt"); + try { + doTest(fileName); + } + catch (Throwable ignore) { + return; + } + throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that."); + } + @TestMetadata("secondaryConstructor.kt") public void testSecondaryConstructor() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/jvmOverloads/secondaryConstructor.kt");