K2: add test for KT-56520, case (7), qualifier receivers (4.2)
This commit covers enum entry vs companion member case, when two companion objects are 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 two candidates with companions. After that it tries to resolve Some as a qualifier, but we have no scope with a single qualifier, so no influence here. With two ambiguous candidates with companions for Some, OVERLOAD_RESOLUTION_AMBIGUITY is reported.
This commit is contained in:
committed by
Space Team
parent
63ce4ba6b0
commit
1f989dce64
+6
@@ -44797,6 +44797,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase2.kt")
|
||||
public void testQualifierEnumEntryOrCompanionMemberCase2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierForStaticCase.kt")
|
||||
public void testQualifierForStaticCase() throws Exception {
|
||||
|
||||
+6
@@ -44797,6 +44797,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase2.kt")
|
||||
public void testQualifierEnumEntryOrCompanionMemberCase2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierForStaticCase.kt")
|
||||
public void testQualifierForStaticCase() throws Exception {
|
||||
|
||||
+6
@@ -42675,6 +42675,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase2.kt")
|
||||
public void testQualifierEnumEntryOrCompanionMemberCase2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierForStaticCase.kt")
|
||||
public void testQualifierForStaticCase() throws Exception {
|
||||
|
||||
+6
@@ -42795,6 +42795,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase2.kt")
|
||||
public void testQualifierEnumEntryOrCompanionMemberCase2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierForStaticCase.kt")
|
||||
public void testQualifierForStaticCase() throws Exception {
|
||||
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// ISSUE: KT-56520 (case 7, enum entry vs companion member, one companion in scope)
|
||||
// FIR_DUMP
|
||||
|
||||
// FILE: some/Some.kt
|
||||
package some
|
||||
|
||||
enum class Some {
|
||||
foo; // (1)
|
||||
|
||||
companion object {}
|
||||
}
|
||||
|
||||
// FILE: some2/Some.kt
|
||||
package some2
|
||||
|
||||
enum class Some {
|
||||
foo; // (2)
|
||||
|
||||
companion object {
|
||||
val foo = "2'" // (2')
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: some3/Some.java
|
||||
package some3;
|
||||
|
||||
public enum Some {
|
||||
foo; // (3)
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import some.*
|
||||
import some2.*
|
||||
import some3.*
|
||||
|
||||
fun test() = <!OVERLOAD_RESOLUTION_AMBIGUITY!>Some<!>.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
FILE: Some.kt
|
||||
package some
|
||||
|
||||
public final enum class Some : R|kotlin/Enum<some/Some>| {
|
||||
private constructor(): R|some/Some| {
|
||||
super<R|kotlin/Enum<some/Some>|>()
|
||||
}
|
||||
|
||||
public final static enum entry foo: R|some/Some|
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|some/Some.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final static fun values(): R|kotlin/Array<some/Some>| {
|
||||
}
|
||||
|
||||
public final static fun valueOf(value: R|kotlin/String|): R|some/Some| {
|
||||
}
|
||||
|
||||
public final static val entries: R|kotlin/enums/EnumEntries<some/Some>|
|
||||
public get(): R|kotlin/enums/EnumEntries<some/Some>|
|
||||
|
||||
}
|
||||
FILE: Some.kt
|
||||
package some2
|
||||
|
||||
public final enum class Some : R|kotlin/Enum<some2/Some>| {
|
||||
private constructor(): R|some2/Some| {
|
||||
super<R|kotlin/Enum<some2/Some>|>()
|
||||
}
|
||||
|
||||
public final static enum entry foo: R|some2/Some|
|
||||
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|
|
||||
|
||||
}
|
||||
|
||||
public final static fun values(): R|kotlin/Array<some2/Some>| {
|
||||
}
|
||||
|
||||
public final static fun valueOf(value: R|kotlin/String|): R|some2/Some| {
|
||||
}
|
||||
|
||||
public final static val entries: R|kotlin/enums/EnumEntries<some2/Some>|
|
||||
public get(): R|kotlin/enums/EnumEntries<some2/Some>|
|
||||
|
||||
}
|
||||
FILE: main.kt
|
||||
public final fun test(): <ERROR TYPE REF: Unresolved name: foo> {
|
||||
^test <Ambiguity: Some, [some/Some, some2/Some]>#.<Unresolved name: foo>#
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// ISSUE: KT-56520 (case 7, enum entry vs companion member, one companion in scope)
|
||||
// FIR_DUMP
|
||||
|
||||
// FILE: some/Some.kt
|
||||
package some
|
||||
|
||||
enum class Some {
|
||||
foo; // (1)
|
||||
|
||||
companion object {}
|
||||
}
|
||||
|
||||
// FILE: some2/Some.kt
|
||||
package some2
|
||||
|
||||
enum class Some {
|
||||
foo; // (2)
|
||||
|
||||
companion object {
|
||||
val foo = "2'" // (2')
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: some3/Some.java
|
||||
package some3;
|
||||
|
||||
public enum Some {
|
||||
foo; // (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/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase2.kt")
|
||||
public void testQualifierEnumEntryOrCompanionMemberCase2() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase2.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("qualifierForStaticCase.kt")
|
||||
public void testQualifierForStaticCase() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user