Forbid callable references to members and extensions with empty LHS

This syntax is reserved to be likely used in the future as a shorthand for
"this::foo" where the resulting expression doesn't take the receiver as a
parameter but has "this" already bound to it
This commit is contained in:
Alexander Udalov
2015-10-02 21:56:15 +03:00
parent f310d4c10e
commit 661f4efc68
48 changed files with 114 additions and 378 deletions
@@ -6,7 +6,7 @@ class A(var g: A) {
val f: Int = 0
fun test() {
val fRef: KProperty1<A, Int> = ::f
val gRef: KMutableProperty1<A, A> = ::g
val fRef: KProperty1<A, Int> = A::f
val gRef: KMutableProperty1<A, A> = A::g
}
}
@@ -1,15 +0,0 @@
// !DIAGNOSTICS:-UNUSED_VARIABLE
import kotlin.reflect.*
class A {
fun test() {
val fooRef: KProperty1<A, String> = ::foo
val barRef: KMutableProperty1<A, Int> = ::bar
}
}
val A.foo: String get() = ""
var A.bar: Int
get() = 42
set(value) { }
@@ -1,12 +0,0 @@
package
public var A.bar: kotlin.Int
public val A.foo: kotlin.String
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 final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -6,7 +6,7 @@ class A(var g: A) {
val f: Int = 0
fun test() {
checkSubtype<KProperty1<A, Int>>(::f)
checkSubtype<KMutableProperty1<A, A>>(::g)
checkSubtype<KProperty1<A, Int>>(A::f)
checkSubtype<KMutableProperty1<A, A>>(A::g)
}
}
@@ -1,23 +0,0 @@
// !CHECK_TYPE
import kotlin.reflect.*
class A {
val foo: Unit = Unit
var bar: String = ""
var self: A
get() = this
set(value) { }
}
fun A.test() {
val x = ::foo
val y = ::bar
val z = ::self
checkSubtype<KProperty1<A, Unit>>(x)
checkSubtype<KMutableProperty1<A, String>>(y)
checkSubtype<KMutableProperty1<A, A>>(z)
y.set(z.get(A()), x.get(A()).toString())
}
@@ -1,13 +0,0 @@
package
public fun A.test(): kotlin.Unit
public final class A {
public constructor A()
public final var bar: kotlin.String
public final val foo: kotlin.Unit
public final var self: 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
}