diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index 05c1566b41c..49ec7f23267 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -11609,6 +11609,22 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/destructuring") + @TestDataPath("$PROJECT_ROOT") + public class Destructuring { + @Test + public void testAllFilesPresentInDestructuring() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/destructuring"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("delegationInDestructuring.kt") + public void testDelegationInDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index ee74e1a4ea4..ac33d9f23f9 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -11609,6 +11609,22 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/destructuring") + @TestDataPath("$PROJECT_ROOT") + public class Destructuring { + @Test + public void testAllFilesPresentInDestructuring() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/destructuring"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("delegationInDestructuring.kt") + public void testDelegationInDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index ed7febe0aa5..91f85bbfbc4 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -11603,6 +11603,22 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/destructuring") + @TestDataPath("$PROJECT_ROOT") + public class Destructuring { + @Test + public void testAllFilesPresentInDestructuring() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/destructuring"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("delegationInDestructuring.kt") + public void testDelegationInDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 24abf027a04..cfbe1730ad0 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -11609,6 +11609,22 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/destructuring") + @TestDataPath("$PROJECT_ROOT") + public class Destructuring { + @Test + public void testAllFilesPresentInDestructuring() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/destructuring"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("delegationInDestructuring.kt") + public void testDelegationInDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirDeclarationBuilder.kt b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirDeclarationBuilder.kt index 437f6d8bf7e..e73360a418f 100644 --- a/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirDeclarationBuilder.kt +++ b/compiler/fir/raw-fir/light-tree2fir/src/org/jetbrains/kotlin/fir/lightTree/converter/LightTreeRawFirDeclarationBuilder.kt @@ -1475,6 +1475,8 @@ class LightTreeRawFirDeclarationBuilder( MODIFIER_LIST -> annotations += convertAnnotationList(it) VAR_KEYWORD -> isVar = true DESTRUCTURING_DECLARATION_ENTRY -> entries += convertDestructingDeclarationEntry(it) + // Property delegates should be ignored as they aren't a valid initializers + PROPERTY_DELEGATE -> {} else -> if (it.isExpression()) firExpression = expressionConverter.getAsFirExpression(it, "Initializer required for destructuring declaration") } diff --git a/compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.fir.kt b/compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.fir.kt new file mode 100644 index 00000000000..2e828eaa02e --- /dev/null +++ b/compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.fir.kt @@ -0,0 +1,6 @@ +// WITH_STDLIB + +fun foo() { + val (a, b) by listOf(1, 2) + val (c, d) by lazy { listOf(3, 4) } +} diff --git a/compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.kt b/compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.kt new file mode 100644 index 00000000000..e28061c03f7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.kt @@ -0,0 +1,6 @@ +// WITH_STDLIB + +fun foo() { + val (a, b) by listOf(1, 2) + val (c, d) by lazy { listOf(3, 4) } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index a288d485931..95870d18c6e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -11609,6 +11609,22 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/destructuring") + @TestDataPath("$PROJECT_ROOT") + public class Destructuring { + @Test + public void testAllFilesPresentInDestructuring() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/destructuring"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("delegationInDestructuring.kt") + public void testDelegationInDestructuring() throws Exception { + runTest("compiler/testData/diagnostics/tests/destructuring/delegationInDestructuring.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/duplicateJvmSignature") @TestDataPath("$PROJECT_ROOT")