Prohibit callable references to object members

To be able to make them more useful in the future, i.e. bound to the object
instance
This commit is contained in:
Alexander Udalov
2015-10-14 16:39:43 +03:00
parent 63dfe13c43
commit ced1edcf98
26 changed files with 122 additions and 218 deletions
@@ -1,17 +0,0 @@
import A.foo
import A.bar
object A {
fun foo() = "O"
fun String.foo() = "K"
@JvmStatic
fun bar(s: Int) = "OK"
}
fun box(): String {
val static = (::bar)(0)
if (static != "OK") return "1"
return (::foo)() + (String::foo)("")
}
@@ -1,13 +0,0 @@
object A {
var result = "Fail"
fun foo() {
result = "OK"
}
}
fun box(): String {
val x = A::foo
x(A)
return A.result
}
@@ -1,13 +0,0 @@
object A {
var result = "Fail"
fun foo(newResult: String) {
result = newResult
}
}
fun box(): String {
val x = A::foo
x(A, "OK")
return A.result
}
@@ -1,15 +0,0 @@
class A {
companion object B {
var state: String = "12345"
}
}
fun box(): String {
val p = A.B::state
if (p.name != "state") return "Fail state: ${p.name}"
if (p.get(A.B) != "12345") return "Fail value: ${p.get(A.B)}"
p.set(A.B, "OK")
return p[A.B]
}
@@ -1,33 +0,0 @@
import A.foo
import A.bar
import A.baz
object A {
var foo = "NotOk"
var String.foo: String
get() = "K"
set(i) {}
@JvmStatic
val bar: String = "OK"
@JvmStatic
val String.baz: String
get() = "OK"
}
fun box(): String {
val static = (::bar).get()
if (static != "OK") return static
val staticExt = (String::baz).get("a")
if (staticExt != "OK") return staticExt
val nonExt = ::foo
nonExt.set("O")
val ext = String::foo
ext.set("", "Whatever")
return nonExt.get() + ext.get("")
}