Qualifier no longer defers "(nested) class vs package" resolution.

Consider FQN 'a.b.c'.
If 'a' is a classifier in the current scope,
    resolve rest in the corresponding class scope.
Otherwise (if 'a' is a package),
    find the maximum possible prefix 'a.b' resolving to a package,
    resolve rest in the corresponding package scope.
This commit is contained in:
Dmitry Petrov
2015-10-29 16:45:53 +03:00
parent a950f36fd7
commit e1cb13bd90
10 changed files with 169 additions and 62 deletions
@@ -30,9 +30,10 @@ fun test(ab_c: c) {
ab_c3.ab_c()
}
fun test2(a_bc: a.b.c) {
a_bc.<!UNRESOLVED_REFERENCE!>a_bc<!>() // todo
a_bc.ab_c() // todo
// NB according to the maximum package prefix rule, 'a.b.c' denotes 'c' in package 'a.b' (thus ab_c, not a_bc)
fun test2(ab_c: a.b.c) {
ab_c.<!UNRESOLVED_REFERENCE!>a_bc<!>()
ab_c.ab_c()
}
@@ -66,7 +67,7 @@ fun test(a_b: b) {
_ab._ab()
val _ab2 = a.b()
_ab2.<!UNRESOLVED_REFERENCE!>_ab<!>() // todo
_ab2._ab()
}
fun test2(_ab: a.b) {
@@ -42,7 +42,7 @@ package a {
package
public fun test(/*0*/ ab_c: a.b.c): kotlin.Unit
public fun test2(/*0*/ a_bc: a.b.c): kotlin.Unit
public fun test2(/*0*/ ab_c: a.b.c): kotlin.Unit
package a {
@@ -110,3 +110,5 @@ package a {
// -- Module: <top_m1> --
}
}
@@ -0,0 +1,15 @@
// MODULE: m1
// FILE: a.kt
package a
class b {
fun a_b() {}
}
// MODULE: m2(m1)
// FILE: b.kt
package test
class a
val x = a.<!UNRESOLVED_REFERENCE!>b<!>()
@@ -0,0 +1,37 @@
// -- Module: <m1> --
package
package a {
public final class b {
public constructor b()
public final fun a_b(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
// -- Module: <m2> --
package
package a {
public final class b {
// -- Module: <m1> --
}
}
package test {
public val x: [ERROR : Type for a.b()]
public final class a {
public constructor a()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -40,5 +40,5 @@ fun test(_ab: a.b) {
_ab._ab()
val _ab2 = a.b()
_ab2.<!UNRESOLVED_REFERENCE!>_ab<!>() // todo
_ab2._ab() // todo
}
@@ -25,10 +25,10 @@ class a {}
fun test(a_: a.<!UNRESOLVED_REFERENCE!>b<!>) {
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a_<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a_b<!>()
val a_2 = a.b()
a_2.a_b() // todo: must be unresolved
a_2.<!UNRESOLVED_REFERENCE!>some_ab<!>()
a_2.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a_()<!>
val a_2 = a.<!UNRESOLVED_REFERENCE!>b<!>()
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a_2<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a_b<!>()
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a_2<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>some_ab<!>()
<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a_2<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a_<!>()
}
// FILE: c2.kt
@@ -44,7 +44,7 @@ fun test(_ab: a.b) {
_ab.other2_ab()
val _ab2 = a.b()
_ab2.<!UNRESOLVED_REFERENCE!>other2_ab<!>() // todo
_ab2.other2_ab()
}
// FILE: c3.kt
@@ -54,5 +54,5 @@ fun test(_ab: a.b) {
_ab.some_ab()
val _ab2 = a.b()
_ab2.<!UNRESOLVED_REFERENCE!>some_ab<!>() // todo
_ab2.some_ab()
}