diff --git a/compiler/testData/codegen/box/secondaryConstructors/accessToCompanion.kt b/compiler/testData/codegen/box/secondaryConstructors/accessToCompanion.kt index f21de9b9b0a..430d61430fc 100644 --- a/compiler/testData/codegen/box/secondaryConstructors/accessToCompanion.kt +++ b/compiler/testData/codegen/box/secondaryConstructors/accessToCompanion.kt @@ -4,18 +4,14 @@ class A(val result: Int) { val prop = 2 val C = 3 } - object B { - fun bar(): Int = 4 - val prop = 5 - } object C { } - constructor() : this(foo() + prop + B.bar() + B.prop + C) + constructor() : this(foo() + prop + C) } fun box(): String { val result = A().result - if (result != 15) return "fail: $result" + if (result != 6) return "fail: $result" return "OK" } diff --git a/compiler/testData/codegen/box/secondaryConstructors/accessToNestedObject.kt b/compiler/testData/codegen/box/secondaryConstructors/accessToNestedObject.kt new file mode 100644 index 00000000000..2a093d7f477 --- /dev/null +++ b/compiler/testData/codegen/box/secondaryConstructors/accessToNestedObject.kt @@ -0,0 +1,19 @@ +// TODO enable for JS backend too when KT-6203 will be fixed +// TARGET_BACKEND: JVM + +class A(val result: Int) { + object B { + fun bar(): Int = 4 + val prop = 5 + } + object C { + } + + constructor() : this(B.bar() + B.prop) +} + +fun box(): String { + val result = A().result + if (result != 9) return "fail: $result" + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index b4ed32c7436..e2d40130684 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -6402,6 +6402,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("accessToNestedObject.kt") + public void testAccessToNestedObject() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/secondaryConstructors/accessToNestedObject.kt"); + doTest(fileName); + } + public void testAllFilesPresentInSecondaryConstructors() throws Exception { JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/secondaryConstructors"), Pattern.compile("^(.+)\\.kt$"), true); } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SecondaryConstructorTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SecondaryConstructorTestGenerated.java index 19263d96f55..59932cf3efb 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SecondaryConstructorTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SecondaryConstructorTestGenerated.java @@ -31,6 +31,12 @@ import java.util.regex.Pattern; @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) public class SecondaryConstructorTestGenerated extends AbstractSecondaryConstructorTest { + @TestMetadata("accessToNestedObject.kt") + public void ignoredAccessToNestedObject() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/secondaryConstructors/accessToNestedObject.kt"); + doTest(fileName); + } + @TestMetadata("innerClasses.kt") public void ignoredInnerClasses() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/secondaryConstructors/innerClasses.kt");