K2: add test for KT-56520, case (3), class literals

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, in case
it's used as a receiver itself (::class counts as a selector equivalent).
This commit is contained in:
Mikhail Glukhikh
2023-10-26 15:50:11 +02:00
committed by Space Team
parent 6fb88102a5
commit 22d083a7a9
7 changed files with 53 additions and 0 deletions
@@ -44761,6 +44761,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt");
}
@Test
@TestMetadata("constructorCase.kt")
public void testConstructorCase() throws Exception {
@@ -44761,6 +44761,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt");
}
@Test
@TestMetadata("constructorCase.kt")
public void testConstructorCase() throws Exception {
@@ -42639,6 +42639,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt");
}
@Test
@TestMetadata("constructorCase.kt")
public void testConstructorCase() throws Exception {
@@ -42759,6 +42759,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt");
}
@Test
@TestMetadata("constructorCase.kt")
public void testConstructorCase() throws Exception {
@@ -0,0 +1,4 @@
FILE: test.kt
public final fun test(): R|kotlin/reflect/KClass<kotlin/collections/HashMap<*, *>>| {
^test <getClass>(Q|kotlin/collections/HashMap|)
}
@@ -0,0 +1,19 @@
// FIR_IDENTICAL
// ISSUE: KT-56520 (case 3)
// FIR_DUMP
// FULL_JDK
// FILE: some/HashMap.java
package some;
public class HashMap<K, V> extends java.util.HashMap<K, V> {}
// FILE: test.kt
import java.util.*
import some.*
// K1: misses both some.HashMap and java.util.HashMap due to ambiguous classifiers, takes kotlin.collections.HashMap from the next scope
// K2: works the same way currently. See logic in BodyResolveComponents.resolveRootPartOfQualifier
fun test() = HashMap::class
@@ -44819,6 +44819,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
}
@Test
@TestMetadata("classLiteralCase.kt")
public void testClassLiteralCase() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/classLiteralCase.kt");
}
@Test
@TestMetadata("constructorCase.kt")
public void testConstructorCase() throws Exception {