K2: add test for KT-56520, case (7), qualifier receivers (2.2)
This commit covers object vs companion member vs static member case but now we have two different companions (first is empty) 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 some/Some & some2/Some because both of them have a companion. This means ambiguity. After it tries to resolve Some as a qualifier, but we have no scope with a single qualifier, so finally we prefer to report ambiguity from variable access resolve.
This commit is contained in:
committed by
Space Team
parent
ab161333a7
commit
602801dcfd
+34
@@ -0,0 +1,34 @@
|
||||
// ISSUE: KT-56520 (case 7, object vs companion member vs static member, two companions 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() = <!OVERLOAD_RESOLUTION_AMBIGUITY!>Some<!>.<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
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|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|some/Some.Companion| {
|
||||
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(): <ERROR TYPE REF: Unresolved name: foo> {
|
||||
^test <Ambiguity: Some, [some/Some, some2/Some]>#.<Unresolved name: foo>#
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// ISSUE: KT-56520 (case 7, object vs companion member vs static member, two companions 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<!>
|
||||
Reference in New Issue
Block a user