diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java index cdb2cb7865c..191ac1a8b3c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/BoxJsTestGenerated.java @@ -7736,6 +7736,18 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest { runTest("js/js.translator/testData/box/nestedTypes/innerReferenceFromChild.kt"); } + @Test + @TestMetadata("innerWithMultipleArgs.kt") + public void testInnerWithMultipleArgs() throws Exception { + runTest("js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt"); + } + + @Test + @TestMetadata("innerWithSecondaryConstructor.kt") + public void testInnerWithSecondaryConstructor() throws Exception { + runTest("js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/FirJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/FirJsTestGenerated.java index 604c65eade5..fe2f0bef9aa 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/FirJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/FirJsTestGenerated.java @@ -8208,6 +8208,18 @@ public class FirJsTestGenerated extends AbstractFirJsTest { runTest("js/js.translator/testData/box/nestedTypes/innerReferenceFromChild.kt"); } + @Test + @TestMetadata("innerWithMultipleArgs.kt") + public void testInnerWithMultipleArgs() throws Exception { + runTest("js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt"); + } + + @Test + @TestMetadata("innerWithSecondaryConstructor.kt") + public void testInnerWithSecondaryConstructor() throws Exception { + runTest("js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java index a436e93805c..fa2bda92a4a 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrBoxJsTestGenerated.java @@ -8208,6 +8208,18 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest { runTest("js/js.translator/testData/box/nestedTypes/innerReferenceFromChild.kt"); } + @Test + @TestMetadata("innerWithMultipleArgs.kt") + public void testInnerWithMultipleArgs() throws Exception { + runTest("js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt"); + } + + @Test + @TestMetadata("innerWithSecondaryConstructor.kt") + public void testInnerWithSecondaryConstructor() throws Exception { + runTest("js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt"); + } + @Test @TestMetadata("nested.kt") public void testNested() throws Exception { diff --git a/js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt b/js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt new file mode 100644 index 00000000000..541af069679 --- /dev/null +++ b/js/js.translator/testData/box/nestedTypes/innerWithMultipleArgs.kt @@ -0,0 +1,44 @@ +// EXPECTED_REACHABLE_NODES: 1286 +// WITH_STDLIB + +package foo + +open class NotExportedParent(val a: Int, val b: Int) { + inner class Inner(val c: Int, val d: Int) { + fun foo() = a + b + c + d + } + + inner class WithVararg(vararg val values: Int) { + fun foo() = a + b + values.sum() + } +} + +@JsExport +open class ExportedParent(val a: Int, val b: Int) { + inner class Inner(val c: Int, val d: Int) { + fun foo() = a + b + c + d + } + + inner class WithVararg(vararg val values: Int) { + fun foo() = a + b + values.sum() + } +} + +fun box(): String { + val notExportedParent = NotExportedParent(1, 2) + val notExportedInner = notExportedParent.Inner(3, 4) + val notExportedInnerWithVararg = notExportedParent.WithVararg(3, 4) + + if (notExportedInner.foo() != 10) return "Failed: something wrong with multiple arguments inside not-exported inner class primary constructor" + if (notExportedInnerWithVararg.foo() != 10) return "Failed: something wrong with vararg arguments inside not-exported inner class primary constructor" + + val exportedParent = ExportedParent(1, 2) + val exportedInner = exportedParent.Inner(3, 4) + val exportedInnerWithVararg = exportedParent.WithVararg(3, 4) + + if (exportedInner.foo() != 10) return "Failed: something wrong with multiple arguments inside exported inner class primary constructor" + if (exportedInnerWithVararg.foo() != 10) return "Failed: something wrong with vararg arguments inside exported inner class primary constructor" + + return "OK" +} + diff --git a/js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt b/js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt new file mode 100644 index 00000000000..97d534b84d3 --- /dev/null +++ b/js/js.translator/testData/box/nestedTypes/innerWithSecondaryConstructor.kt @@ -0,0 +1,48 @@ +// EXPECTED_REACHABLE_NODES: 1286 +package foo + +open class NotExportedParent(val o: String) { + constructor(): this("O") + + inner class Inner(val k: String) { + constructor(): this("K") + fun foo() = o + k + } +} + +@JsExport +open class ExportedParent(val o: String) { + @JsName("createO") + constructor(): this("O") + + inner class Inner(val k: String) { + @JsName("createK") + constructor(): this("K") + fun foo() = o + k + } +} + +fun box(): String { + val notExportedParent = NotExportedParent("OO") + + if (notExportedParent.Inner("KK").foo() != "OOKK") return "Fail1: primary constructor capturing" + if (notExportedParent.Inner().foo() != "OOK") return "Fail2: inner secondary constructor capturing" + + val notExportedParentDefault = NotExportedParent() + + if (notExportedParentDefault.Inner("KK").foo() != "OKK") return "Fail3: primary constructor capturing" + if (notExportedParentDefault.Inner().foo() != "OK") return "Fail4: inner secondary constructor capturing" + + val exportedParent = ExportedParent("OO") + + if (exportedParent.Inner("KK").foo() != "OOKK") return "Fail5: exported primary constructor capturing" + if (exportedParent.Inner().foo() != "OOK") return "Fail6: exported inner secondary constructor capturing" + + val exportedParentDefault = ExportedParent() + + if (exportedParentDefault.Inner("KK").foo() != "OKK") return "Fail7: exported primary constructor capturing" + if (exportedParentDefault.Inner().foo() != "OK") return "Fail8: exported inner secondary constructor capturing" + + return "OK" +} +