From c2ac9daa7f00cbbd079e27652e25c27b1503a07b Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Mon, 30 Oct 2023 11:41:15 +0100 Subject: [PATCH] K2: add test for KT-56520, case (4), callable references (unbound) Again, both frontends here ignored classifiers from explicit star imported scope (some.HashMap, java.util.HashMap) because of their ambiguity. In case of K2, it works so due to logic in BodyResolveComponents.resolveRootPartOfQualifier. This function is called to resolve qualifier without receiver. See also cases (3) and (7). --- ...CompilerTestFE10TestdataTestGenerated.java | 6 ++++++ ...sticCompilerFE10TestDataTestGenerated.java | 6 ++++++ ...eeOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ ...siOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ .../callableReferenceUnboundCase.fir.txt | 4 ++++ .../callableReferenceUnboundCase.kt | 20 +++++++++++++++++++ .../test/runners/DiagnosticTestGenerated.java | 6 ++++++ 7 files changed, 54 insertions(+) create mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.fir.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.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 134cb012edd..aa01f4d87f8 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 @@ -44767,6 +44767,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt"); } + @Test + @TestMetadata("callableReferenceUnboundCase.kt") + public void testCallableReferenceUnboundCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.kt"); + } + @Test @TestMetadata("classLiteralCase.kt") public void testClassLiteralCase() 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 9fb5b6795b9..fe33fb84429 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 @@ -44767,6 +44767,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt"); } + @Test + @TestMetadata("callableReferenceUnboundCase.kt") + public void testCallableReferenceUnboundCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.kt"); + } + @Test @TestMetadata("classLiteralCase.kt") public void testClassLiteralCase() 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 21e49e52873..c4f62dafe5e 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 @@ -42645,6 +42645,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt"); } + @Test + @TestMetadata("callableReferenceUnboundCase.kt") + public void testCallableReferenceUnboundCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.kt"); + } + @Test @TestMetadata("classLiteralCase.kt") public void testClassLiteralCase() 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 d5c7cf8358b..da1aea45aaf 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 @@ -42765,6 +42765,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt"); } + @Test + @TestMetadata("callableReferenceUnboundCase.kt") + public void testCallableReferenceUnboundCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.kt"); + } + @Test @TestMetadata("classLiteralCase.kt") public void testClassLiteralCase() throws Exception { diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.fir.txt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.fir.txt new file mode 100644 index 00000000000..42894825997 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.fir.txt @@ -0,0 +1,4 @@ +FILE: test.kt + public final fun test(): R|kotlin/reflect/KProperty1, kotlin/Int>| { + ^test Q|kotlin/collections/HashMap|::R|SubstitutionOverride| + } diff --git a/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.kt b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.kt new file mode 100644 index 00000000000..f16dbcc715c --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.kt @@ -0,0 +1,20 @@ +// FIR_IDENTICAL +// ISSUE: KT-56520 (case 4, unbound) +// FIR_DUMP +// FULL_JDK + +// FILE: some/HashMap.java + +package some; + +public class HashMap extends java.util.HashMap {} + +// FILE: test.kt + +import java.util.* +import some.* + +fun test() = + // Ok in both K1 & K2. + // K1 & K2 resolve this to kotlin.collections.HashMap. + HashMap::size 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 b7828f51377..c269408861e 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 @@ -44825,6 +44825,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceCase.kt"); } + @Test + @TestMetadata("callableReferenceUnboundCase.kt") + public void testCallableReferenceUnboundCase() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/callableReferenceUnboundCase.kt"); + } + @Test @TestMetadata("classLiteralCase.kt") public void testClassLiteralCase() throws Exception {