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:
Mikhail Glukhikh
2023-10-30 13:55:26 +01:00
committed by Space Team
parent c2ac9daa7f
commit ab161333a7
8 changed files with 137 additions and 0 deletions
@@ -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
@@ -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|
}
@@ -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<!>