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 f9c90b84a30..5e53d8ae3b8 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 @@ -27278,6 +27278,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/operatorsOverloading/compareToNullable.kt"); } + @Test + @TestMetadata("destructuringDeclarationWithInvoke.kt") + public void testDestructuringDeclarationWithInvoke() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.kt"); + } + @Test @TestMetadata("EqualsOperatorOverrideHierarchies.kt") public void testEqualsOperatorOverrideHierarchies() throws Exception { 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 531ef7734fc..b4162e4db1a 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 @@ -27278,6 +27278,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/operatorsOverloading/compareToNullable.kt"); } + @Test + @TestMetadata("destructuringDeclarationWithInvoke.kt") + public void testDestructuringDeclarationWithInvoke() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.kt"); + } + @Test @TestMetadata("EqualsOperatorOverrideHierarchies.kt") public void testEqualsOperatorOverrideHierarchies() throws Exception { 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 21868736656..a585ad6e588 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 @@ -25194,6 +25194,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/operatorsOverloading/compareToNullable.kt"); } + @Test + @TestMetadata("destructuringDeclarationWithInvoke.kt") + public void testDestructuringDeclarationWithInvoke() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.kt"); + } + @Test @TestMetadata("EqualsOperatorOverrideHierarchies.kt") public void testEqualsOperatorOverrideHierarchies() throws Exception { 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 7a246ea7894..a0d575e5135 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 @@ -25200,6 +25200,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/operatorsOverloading/compareToNullable.kt"); } + @Test + @TestMetadata("destructuringDeclarationWithInvoke.kt") + public void testDestructuringDeclarationWithInvoke() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.kt"); + } + @Test @TestMetadata("EqualsOperatorOverrideHierarchies.kt") public void testEqualsOperatorOverrideHierarchies() throws Exception { diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.fir.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.fir.kt new file mode 100644 index 00000000000..0df1d4f9475 --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.fir.kt @@ -0,0 +1,23 @@ +// ISSUE: KT-59715 + +class FunctionComponent { + val component1: () -> String = { "hello" } +} + +class I { + operator fun invoke(): String = "hello" +} + +class InvokeComponent { + val component1: I = I() +} + +fun test_1(c: FunctionComponent) { + val (x) = FunctionComponent() + val (y) = c +} + +fun test_2(c: InvokeComponent) { + val (x) = FunctionComponent() + val (y) = c +} diff --git a/compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.kt b/compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.kt new file mode 100644 index 00000000000..a76f018146d --- /dev/null +++ b/compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.kt @@ -0,0 +1,23 @@ +// ISSUE: KT-59715 + +class FunctionComponent { + val component1: () -> String = { "hello" } +} + +class I { + operator fun invoke(): String = "hello" +} + +class InvokeComponent { + val component1: I = I() +} + +fun test_1(c: FunctionComponent) { + val (x) = FunctionComponent() + val (y) = c +} + +fun test_2(c: InvokeComponent) { + val (x) = FunctionComponent() + val (y) = c +} 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 4f743107345..3a728c97670 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 @@ -27278,6 +27278,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/operatorsOverloading/compareToNullable.kt"); } + @Test + @TestMetadata("destructuringDeclarationWithInvoke.kt") + public void testDestructuringDeclarationWithInvoke() throws Exception { + runTest("compiler/testData/diagnostics/tests/operatorsOverloading/destructuringDeclarationWithInvoke.kt"); + } + @Test @TestMetadata("EqualsOperatorOverrideHierarchies.kt") public void testEqualsOperatorOverrideHierarchies() throws Exception {