From dda7004d667f56a53568f99dcd3ddbe15196feba Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Thu, 26 Oct 2023 10:50:42 +0200 Subject: [PATCH] K2: add test to confirm behavior described in KT-62918 #KT-62918 Obsolete Related to: KT-60086, KT-59920 --- ...CompilerTestFE10TestdataTestGenerated.java | 6 +++ ...sticCompilerFE10TestDataTestGenerated.java | 6 +++ ...eeOldFrontendDiagnosticsTestGenerated.java | 6 +++ ...siOldFrontendDiagnosticsTestGenerated.java | 6 +++ .../exposed/ambiguousAnonymousExposed.fir.kt | 14 ++++++ .../exposed/ambiguousAnonymousExposed.fir.txt | 50 +++++++++++++++++++ .../exposed/ambiguousAnonymousExposed.kt | 14 ++++++ .../test/runners/DiagnosticTestGenerated.java | 6 +++ 8 files changed, 108 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.fir.kt create mode 100644 compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.fir.txt create mode 100644 compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt 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 49c93f87563..d78da2a9212 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 @@ -12350,6 +12350,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exposed"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("ambiguousAnonymousExposed.kt") + public void testAmbiguousAnonymousExposed() throws Exception { + runTest("compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt"); + } + @Test @TestMetadata("delegate.kt") public void testDelegate() 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 52d608eb647..566643ebbdc 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 @@ -12350,6 +12350,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exposed"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("ambiguousAnonymousExposed.kt") + public void testAmbiguousAnonymousExposed() throws Exception { + runTest("compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt"); + } + @Test @TestMetadata("delegate.kt") public void testDelegate() 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 5742b5d5a59..3852eb6c286 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 @@ -12344,6 +12344,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exposed"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("ambiguousAnonymousExposed.kt") + public void testAmbiguousAnonymousExposed() throws Exception { + runTest("compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt"); + } + @Test @TestMetadata("delegate.kt") public void testDelegate() 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 e44729491d6..e72f10027a2 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 @@ -12350,6 +12350,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exposed"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); } + @Test + @TestMetadata("ambiguousAnonymousExposed.kt") + public void testAmbiguousAnonymousExposed() throws Exception { + runTest("compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt"); + } + @Test @TestMetadata("delegate.kt") public void testDelegate() throws Exception { diff --git a/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.fir.kt b/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.fir.kt new file mode 100644 index 00000000000..766f4388782 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.fir.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-62918 +// FIR_DUMP + +class My(val value: T) +interface I1 +interface I2 + +fun foo() = My(object : I1, I2 {}) + +fun fooFoo(): My = My(object : I1, I2 {}) + +internal fun bar() = My(object : I1, I2 {}) + +private fun baz() = My(object : I1, I2 {}) diff --git a/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.fir.txt b/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.fir.txt new file mode 100644 index 00000000000..ed8e8f853e3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.fir.txt @@ -0,0 +1,50 @@ +FILE: ambiguousAnonymousExposed.fir.kt + public final class My : R|kotlin/Any| { + public constructor(value: R|T|): R|My| { + super() + } + + public final val value: R|T| = R|/value| + public get(): R|T| + + } + public abstract interface I1 : R|kotlin/Any| { + } + public abstract interface I2 : R|kotlin/Any| { + } + public final fun foo(): R|My| { + ^foo R|/My.My||>(object : R|I1|, R|I2| { + private constructor(): R|| { + super() + } + + } + ) + } + public final fun fooFoo(): R|My| { + ^fooFoo R|/My.My|(object : R|I1|, R|I2| { + private constructor(): R|| { + super() + } + + } + ) + } + internal final fun bar(): R|My| { + ^bar R|/My.My||>(object : R|I1|, R|I2| { + private constructor(): R|| { + super() + } + + } + ) + } + private final fun baz(): R|My<>| { + ^baz R|/My.My||>(object : R|I1|, R|I2| { + private constructor(): R|| { + super() + } + + } + ) + } diff --git a/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt b/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt new file mode 100644 index 00000000000..11a392bbf4b --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt @@ -0,0 +1,14 @@ +// ISSUE: KT-62918 +// FIR_DUMP + +class My(val value: T) +interface I1 +interface I2 + +fun foo() = My(object : I1, I2 {}) + +fun fooFoo(): My = My(object : I1, I2 {}) + +internal fun bar() = My(object : I1, I2 {}) + +private fun baz() = My(object : I1, I2 {}) 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 43fc4cc7268..197344637af 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 @@ -12350,6 +12350,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exposed"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); } + @Test + @TestMetadata("ambiguousAnonymousExposed.kt") + public void testAmbiguousAnonymousExposed() throws Exception { + runTest("compiler/testData/diagnostics/tests/exposed/ambiguousAnonymousExposed.kt"); + } + @Test @TestMetadata("delegate.kt") public void testDelegate() throws Exception {