K2: add test for KT-56520, case (7), qualifier receivers (1)

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
This commit is contained in:
Mikhail Glukhikh
2023-10-27 15:34:22 +02:00
committed by Space Team
parent 22d083a7a9
commit 168717b811
7 changed files with 127 additions and 0 deletions
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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 {
@@ -0,0 +1,45 @@
FILE: Map.kt
package some
public final class Map : R|kotlin/Any| {
public constructor(): R|some/Map| {
super<R|kotlin/Any|>()
}
public final companion object Companion : R|kotlin/Any| {
private constructor(): R|some/Map.Companion| {
super<R|kotlin/Any|>()
}
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<R|kotlin/Any|>()
}
}
FILE: test.kt
public final fun test(): <ERROR TYPE REF: Unresolved name: of> {
^test Q|kotlin/collections/Map|.<Unresolved name: of>#()
}
FILE: test2.kt
public final fun test2(): <ERROR TYPE REF: Unresolved name: of> {
^test2 Q|kotlin/collections/Map|.<Unresolved name: of>#()
}
FILE: test3.kt
public final fun test3(): R|ft<kotlin/collections/MutableMap<kotlin/String!, kotlin/String!>, kotlin/collections/Map<kotlin/String!, kotlin/String!>?>| {
^test3 Q|java/util/Map|.R|java/util/Map.of*s|<R|kotlin/String|, R|kotlin/String|>()
}
FILE: test4.kt
public final fun test4(): R|kotlin/Int| {
^test4 Q|some/Map|.R|some/Map.Companion.of|()
}
@@ -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.<!UNRESOLVED_REFERENCE!>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.<!UNRESOLVED_REFERENCE!>of<!>()
// FILE: test3.kt
import java.util.Map
fun test3() = Map.of<String, String>()
// FILE: test4.kt
import some.Map
fun test4() = Map.of()
@@ -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 {