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 0f83cecfba3..338a91376fc 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 @@ -44779,6 +44779,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); } + @Test + @TestMetadata("qualifierForStaticCase.kt") + public void testQualifierForStaticCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt"); + } + @Test @TestMetadata("typeCase.kt") public void testTypeCase() 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 576c909ed92..e63bea7e6b0 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 @@ -44779,6 +44779,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); } + @Test + @TestMetadata("qualifierForStaticCase.kt") + public void testQualifierForStaticCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt"); + } + @Test @TestMetadata("typeCase.kt") public void testTypeCase() 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 5538f121cd1..a76158b3cd0 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 @@ -42657,6 +42657,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); } + @Test + @TestMetadata("qualifierForStaticCase.kt") + public void testQualifierForStaticCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt"); + } + @Test @TestMetadata("typeCase.kt") public void testTypeCase() 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 e93c55181bb..85ad9180b04 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 @@ -42777,6 +42777,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); } + @Test + @TestMetadata("qualifierForStaticCase.kt") + public void testQualifierForStaticCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt"); + } + @Test @TestMetadata("typeCase.kt") public void testTypeCase() throws Exception { diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.fir.txt new file mode 100644 index 00000000000..118b2f37fbf --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.fir.txt @@ -0,0 +1,45 @@ +FILE: Map.kt + package some + + public final class Map : R|kotlin/Any| { + public constructor(): R|some/Map| { + super() + } + + public final companion object Companion : R|kotlin/Any| { + private constructor(): R|some/Map.Companion| { + super() + } + + public final fun of(): R|kotlin/Int| { + ^of Int(42) + } + + } + + } +FILE: Map.kt + package other + + public final class Map : R|kotlin/Any| { + public constructor(): R|other/Map| { + super() + } + + } +FILE: test.kt + public final fun test(): { + ^test Q|kotlin/collections/Map|.#() + } +FILE: test2.kt + public final fun test2(): { + ^test2 Q|kotlin/collections/Map|.#() + } +FILE: test3.kt + public final fun test3(): R|ft, kotlin/collections/Map?>| { + ^test3 Q|java/util/Map|.R|java/util/Map.of*s|() + } +FILE: test4.kt + public final fun test4(): R|kotlin/Int| { + ^test4 Q|some/Map|.R|some/Map.Companion.of|() + } diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt new file mode 100644 index 00000000000..de476a3931b --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt @@ -0,0 +1,52 @@ +// FIR_IDENTICAL +// ISSUE: KT-56520 (case 7) +// FIR_DUMP +// JDK_KIND: FULL_JDK_17 +// DIAGNOSTICS: -PLATFORM_CLASS_MAPPED_TO_KOTLIN + +// FILE: some/Map.kt + +package some + +class Map { + companion object { + fun of() = 42 + } +} + +// FILE: other/Map.kt + +package other + +class Map + +// FILE: test.kt + +import java.util.* +import some.* + +// K1: misses both some.Map and java.util.Map due to ambiguous classifiers, takes kotlin.collections.Map from the next scope +// K2: works the same way currently. See logic in BodyResolveComponents.resolveRootPartOfQualifier +// (looks like kotlin.collections.Map.of is not available) +fun test() = Map.of() + +// FILE: test2.kt + +import java.util.* +import other.* + +// K1: misses both some.Map and java.util.Map due to ambiguous classifiers, takes kotlin.collections.Map from the next scope +// K2: works the same way currently. See logic in BodyResolveComponents.resolveRootPartOfQualifier +fun test2() = Map.of() + +// FILE: test3.kt + +import java.util.Map + +fun test3() = Map.of() + +// FILE: test4.kt + +import some.Map + +fun test4() = Map.of() 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 7894f73afab..e71bb5ca80d 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 @@ -44837,6 +44837,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt"); } + @Test + @TestMetadata("qualifierForStaticCase.kt") + public void testQualifierForStaticCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt"); + } + @Test @TestMetadata("typeCase.kt") public void testTypeCase() throws Exception {