diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java index a25cf765ddb..eea32df00db 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java @@ -1663,6 +1663,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt"); } + @Test + @TestMetadata("primaryConstructorParametersInSecondaryConstructor.kt") + public void testPrimaryConstructorParametersInSecondaryConstructor() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.kt"); + } + @Test @TestMetadata("primaryConstructorRequiredForDataClass.kt") public void testPrimaryConstructorRequiredForDataClass() throws Exception { diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 0b39f3cd603..69be6b72d79 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -1449,6 +1449,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt"); } + @TestMetadata("primaryConstructorParametersInSecondaryConstructor.kt") + public void testPrimaryConstructorParametersInSecondaryConstructor() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.kt"); + } + @TestMetadata("primaryConstructorRequiredForDataClass.kt") public void testPrimaryConstructorRequiredForDataClass() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorRequiredForDataClass.kt"); diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.fir.txt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.fir.txt new file mode 100644 index 00000000000..3bde3f8cacb --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.fir.txt @@ -0,0 +1,11 @@ +FILE: primaryConstructorParametersInSecondaryConstructor.kt + public final class A : R|kotlin/Any| { + public constructor(x: R|kotlin/Int|): R|A| { + super() + } + + public constructor(y: R|kotlin/String|, z: R|kotlin/Int| = #): R|A| { + this(R|/z|) + } + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.kt new file mode 100644 index 00000000000..1711dcd21c8 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.kt @@ -0,0 +1,3 @@ +class A(x: Int) { + constructor(y: String, z: Int = x): this(z) +} diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index 3b08fafaf95..2b447dddee8 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -1663,6 +1663,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt"); } + @Test + @TestMetadata("primaryConstructorParametersInSecondaryConstructor.kt") + public void testPrimaryConstructorParametersInSecondaryConstructor() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.kt"); + } + @Test @TestMetadata("primaryConstructorRequiredForDataClass.kt") public void testPrimaryConstructorRequiredForDataClass() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index 0eed0600047..c68de66694a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -1663,6 +1663,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/notASupertype.kt"); } + @Test + @TestMetadata("primaryConstructorParametersInSecondaryConstructor.kt") + public void testPrimaryConstructorParametersInSecondaryConstructor() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/diagnostics/primaryConstructorParametersInSecondaryConstructor.kt"); + } + @Test @TestMetadata("primaryConstructorRequiredForDataClass.kt") public void testPrimaryConstructorRequiredForDataClass() throws Exception { diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt index 0ac15418b54..248e9735372 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveContext.kt @@ -631,8 +631,10 @@ class BodyResolveContext( * special towerDataContext */ withTowerDataMode(FirTowerDataMode.CONSTRUCTOR_HEADER) { - getPrimaryConstructorAllParametersScope()?.let { addLocalScope(it) } - f() + withTowerDataCleanup { + getPrimaryConstructorAllParametersScope()?.let { addLocalScope(it) } + f() + } } } else { withTowerDataCleanup {