Consider callable reference's LHS when resolving RHS

Previous resolution sequence (static scope, nested classes scope, receiver) and
a check against type parameters only made sense when there's a type, not an
expression, on the LHS of a callable reference. Also TransientReceiver is
incorrect in such case because private-to-this visibility check only works for
ExpressionReceiver values
This commit is contained in:
Alexander Udalov
2016-06-15 19:24:46 +03:00
parent 6562a2db19
commit 456ba79793
11 changed files with 180 additions and 25 deletions
@@ -0,0 +1,9 @@
class Outer {
class Nested
inner class Inner
}
fun test() {
Outer()::Inner
Outer()::<!UNRESOLVED_REFERENCE!>Nested<!>
}
@@ -0,0 +1,24 @@
package
public fun test(): kotlin.Unit
public final class Outer {
public constructor Outer()
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
public final inner class Inner {
public constructor Inner()
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
}
public final class Nested {
public constructor Nested()
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
}
}
@@ -0,0 +1,24 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
class Foo<out T>(name: T) {
private var prop: T = name
private set
fun testProp() {
val ok1 = this::prop
val ok2 = this@Foo::prop
val ok3 = object { val y: Any = this@Foo::prop }
val fail1 = Foo(prop)::<!INVISIBLE_MEMBER!>prop<!>
}
fun testFunc() {
val ok1 = this::func
val ok2 = this@Foo::func
val ok3 = object { val y: Any = this@Foo::func }
val fail1 = Foo(prop)::<!INVISIBLE_MEMBER!>func<!>
}
private fun func(t: T): T = t
}
@@ -0,0 +1,12 @@
package
public final class Foo</*0*/ out T> {
public constructor Foo</*0*/ out T>(/*0*/ name: T)
private/*private to this*/ final var prop: T
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
private/*private to this*/ final fun func(/*0*/ t: T): T
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun testFunc(): kotlin.Unit
public final fun testProp(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,14 @@
// FILE: A.java
public class A {
public static void test() {}
}
// FILE: test.kt
enum class E { EN }
fun test() {
A()::<!UNRESOLVED_REFERENCE!>test<!>
E.EN::<!UNRESOLVED_REFERENCE!>valueOf<!>
}
@@ -0,0 +1,32 @@
package
public fun test(): kotlin.Unit
public open 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
// Static members
public open fun test(): kotlin.Unit
}
public final enum class E : kotlin.Enum<E> {
enum entry EN
private constructor E()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<E!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E
public final /*synthesized*/ fun values(): kotlin.Array<E>
}
@@ -0,0 +1,3 @@
fun <T: Any> get(t: T): () -> String {
return t::toString
}
@@ -0,0 +1,3 @@
package
public fun </*0*/ T : kotlin.Any> get(/*0*/ t: T): () -> kotlin.String