diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt index 6f8f27964ac..7963ee37194 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/DefaultParameterValueSubstitutor.kt @@ -256,7 +256,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) { if (constructorDescriptor.valueParameters.isEmpty()) return false if (classOrObject is KtClass && hasSecondaryConstructorsWithNoParameters(classOrObject)) return false - return constructorDescriptor.valueParameters.all { it.declaresDefaultValue() } + return constructorDescriptor.valueParameters.all { it.hasDefaultValue() } } private fun hasSecondaryConstructorsWithNoParameters(klass: KtClass) = diff --git a/compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt b/compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt new file mode 100644 index 00000000000..959210610ab --- /dev/null +++ b/compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt @@ -0,0 +1,31 @@ +// !LANGUAGE: +MultiPlatformProjects +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// FILE: common.kt + +expect class Foo(a: String = "", b: Int = 42) + +// FILE: J.java + +public class J { + public static void test() { + new Foo(); + new Foo("", 42); + } +} + +// FILE: jvm.kt + +import kotlin.test.assertEquals + +actual class Foo actual constructor(a: String, b: Int) { + init { + assertEquals("", a) + assertEquals(42, b) + } +} + +fun box(): String { + J.test() + return "OK" +} 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 7267f6d3f3b..20e2af68005 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 @@ -13236,6 +13236,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("noArgActualConstructor.kt") + public void testNoArgActualConstructor() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt"); + } + @TestMetadata("compiler/testData/codegen/box/multiplatform/defaultArguments") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 3383af29e71..a1fac31a1b8 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -13236,6 +13236,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("noArgActualConstructor.kt") + public void testNoArgActualConstructor() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt"); + } + @TestMetadata("compiler/testData/codegen/box/multiplatform/defaultArguments") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 29e44734eeb..563ba5809a8 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13236,6 +13236,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/multiplatform"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("noArgActualConstructor.kt") + public void testNoArgActualConstructor() throws Exception { + runTest("compiler/testData/codegen/box/multiplatform/noArgActualConstructor.kt"); + } + @TestMetadata("compiler/testData/codegen/box/multiplatform/defaultArguments") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/OutputPrefixPostfixTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/OutputPrefixPostfixTestGenerated.java index 0450484b655..594895d1907 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/OutputPrefixPostfixTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/OutputPrefixPostfixTestGenerated.java @@ -48,4 +48,17 @@ public class OutputPrefixPostfixTestGenerated extends AbstractOutputPrefixPostfi public void testSimpleWithPrefixAndPostfix() throws Exception { runTest("js/js.translator/testData/outputPrefixPostfix/simpleWithPrefixAndPostfix.kt"); } + + @TestMetadata("js/js.translator/testData/outputPrefixPostfix/out") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Out extends AbstractOutputPrefixPostfixTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInOut() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/outputPrefixPostfix/out"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true); + } + } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SourceMapGenerationSmokeTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SourceMapGenerationSmokeTestGenerated.java index 909c4fd90b7..f45e1a57ef8 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SourceMapGenerationSmokeTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/SourceMapGenerationSmokeTestGenerated.java @@ -43,4 +43,17 @@ public class SourceMapGenerationSmokeTestGenerated extends AbstractSourceMapGene public void testMethodCallInMethod() throws Exception { runTest("js/js.translator/testData/sourcemap/methodCallInMethod.kt"); } + + @TestMetadata("js/js.translator/testData/sourcemap/out") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Out extends AbstractSourceMapGenerationSmokeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInOut() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("js/js.translator/testData/sourcemap/out"), Pattern.compile("^([^_](.+))\\.kt$"), TargetBackend.JS, true); + } + } }