K2: add test for KT-56520, case (7), qualifier receivers (2.1)
This commit covers object vs companion member vs static member case in situation with only one companion in the scope. K1 reports UNRESOLVED_REFERENCE here, probably due to ambiguity. About K2, while resolving Some.foo it first tries to resolve Some as a "general" variable access, and gets only some2/Some because it has a companion. Then it tries to resolve Some as a qualifier, but here we have an ambiguity, so finally Some with companion is preferred.
This commit is contained in:
committed by
Space Team
parent
c2ac9daa7f
commit
ab161333a7
+6
@@ -44797,6 +44797,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierStaticObjectOrCompanionMemberCase.kt")
|
||||
public void testQualifierStaticObjectOrCompanionMemberCase() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierStaticObjectOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeCase.kt")
|
||||
public void testTypeCase() throws Exception {
|
||||
|
||||
+6
@@ -44797,6 +44797,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierStaticObjectOrCompanionMemberCase.kt")
|
||||
public void testQualifierStaticObjectOrCompanionMemberCase() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierStaticObjectOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeCase.kt")
|
||||
public void testTypeCase() throws Exception {
|
||||
|
||||
+6
@@ -42675,6 +42675,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierStaticObjectOrCompanionMemberCase.kt")
|
||||
public void testQualifierStaticObjectOrCompanionMemberCase() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierStaticObjectOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeCase.kt")
|
||||
public void testTypeCase() throws Exception {
|
||||
|
||||
+6
@@ -42795,6 +42795,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierStaticObjectOrCompanionMemberCase.kt")
|
||||
public void testQualifierStaticObjectOrCompanionMemberCase() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierStaticObjectOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeCase.kt")
|
||||
public void testTypeCase() throws Exception {
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// ISSUE: KT-56520 (case 7, object vs companion member vs static member, one companion in scope)
|
||||
// FIR_DUMP
|
||||
|
||||
// FILE: some/Some.kt
|
||||
package some
|
||||
|
||||
class Some {
|
||||
object foo {} // (1)
|
||||
|
||||
// companion object {}
|
||||
}
|
||||
|
||||
// FILE: some2/Some.kt
|
||||
package some2
|
||||
|
||||
class Some {
|
||||
companion object {
|
||||
val foo = "2" // (2)
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: some3/Some.java
|
||||
package some3;
|
||||
|
||||
public class Some {
|
||||
public static int foo = 3; // (3)
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import some.*
|
||||
import some2.*
|
||||
import some3.*
|
||||
|
||||
fun test() = Some.foo
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
FILE: Some.kt
|
||||
package some
|
||||
|
||||
public final class Some : R|kotlin/Any| {
|
||||
public constructor(): R|some/Some| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final object foo : R|kotlin/Any| {
|
||||
private constructor(): R|some/Some.foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
FILE: Some.kt
|
||||
package some2
|
||||
|
||||
public final class Some : R|kotlin/Any| {
|
||||
public constructor(): R|some2/Some| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|some2/Some.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val foo: R|kotlin/String| = String(2)
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
FILE: main.kt
|
||||
public final fun test(): R|kotlin/String| {
|
||||
^test Q|some2/Some|.R|some2/Some.Companion.foo|
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// ISSUE: KT-56520 (case 7, object vs companion member vs static member, one companion in scope)
|
||||
// FIR_DUMP
|
||||
|
||||
// FILE: some/Some.kt
|
||||
package some
|
||||
|
||||
class Some {
|
||||
object foo {} // (1)
|
||||
|
||||
// companion object {}
|
||||
}
|
||||
|
||||
// FILE: some2/Some.kt
|
||||
package some2
|
||||
|
||||
class Some {
|
||||
companion object {
|
||||
val foo = "2" // (2)
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: some3/Some.java
|
||||
package some3;
|
||||
|
||||
public class Some {
|
||||
public static int foo = 3; // (3)
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import some.*
|
||||
import some2.*
|
||||
import some3.*
|
||||
|
||||
fun test() = <!UNRESOLVED_REFERENCE!>Some<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>foo<!>
|
||||
Generated
+6
@@ -44855,6 +44855,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierForStaticCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierStaticObjectOrCompanionMemberCase.kt")
|
||||
public void testQualifierStaticObjectOrCompanionMemberCase() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierStaticObjectOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("typeCase.kt")
|
||||
public void testTypeCase() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user