mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 08:31:29 +00:00
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:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user