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:
Vendored
-17
@@ -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)("")
|
||||
}
|
||||
Vendored
-13
@@ -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
|
||||
}
|
||||
Vendored
-13
@@ -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
|
||||
}
|
||||
-15
@@ -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]
|
||||
}
|
||||
Vendored
-33
@@ -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("")
|
||||
}
|
||||
Reference in New Issue
Block a user