K2: add test for KT-56520, case (7), qualifier receivers (4.1)
This commit covers enum entry vs companion member case, when one companion object is 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 the only candidate with companion. After that it tries to resolve Some as a qualifier, but we have no scope with a single qualifier, so no influence here. Finally during foo resolve it should choose between enum entry and companion member, and enum entry wins due to KT-37591.
This commit is contained in:
committed by
Space Team
parent
76b2b9fc66
commit
63ce4ba6b0
+6
@@ -44791,6 +44791,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase.kt")
|
||||||
|
public void testQualifierEnumEntryOrCompanionMemberCase() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("qualifierForStaticCase.kt")
|
@TestMetadata("qualifierForStaticCase.kt")
|
||||||
public void testQualifierForStaticCase() throws Exception {
|
public void testQualifierForStaticCase() throws Exception {
|
||||||
|
|||||||
+6
@@ -44791,6 +44791,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase.kt")
|
||||||
|
public void testQualifierEnumEntryOrCompanionMemberCase() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("qualifierForStaticCase.kt")
|
@TestMetadata("qualifierForStaticCase.kt")
|
||||||
public void testQualifierForStaticCase() throws Exception {
|
public void testQualifierForStaticCase() throws Exception {
|
||||||
|
|||||||
+6
@@ -42669,6 +42669,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase.kt")
|
||||||
|
public void testQualifierEnumEntryOrCompanionMemberCase() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("qualifierForStaticCase.kt")
|
@TestMetadata("qualifierForStaticCase.kt")
|
||||||
public void testQualifierForStaticCase() throws Exception {
|
public void testQualifierForStaticCase() throws Exception {
|
||||||
|
|||||||
+6
@@ -42789,6 +42789,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase.kt")
|
||||||
|
public void testQualifierEnumEntryOrCompanionMemberCase() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("qualifierForStaticCase.kt")
|
@TestMetadata("qualifierForStaticCase.kt")
|
||||||
public void testQualifierForStaticCase() throws Exception {
|
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() = Some.foo
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
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 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(): R|some2/Some| {
|
||||||
|
^test Q|some2/Some|.R|some2/Some.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
@@ -44849,6 +44849,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/constructorCaseSpace.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("qualifierEnumEntryOrCompanionMemberCase.kt")
|
||||||
|
public void testQualifierEnumEntryOrCompanionMemberCase() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/testsWithStdLib/resolve/ambiguousTypeReferences/qualifierEnumEntryOrCompanionMemberCase.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("qualifierForStaticCase.kt")
|
@TestMetadata("qualifierForStaticCase.kt")
|
||||||
public void testQualifierForStaticCase() throws Exception {
|
public void testQualifierForStaticCase() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user