Support closures in codegen for callable references
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
class Outer {
|
||||
val result = "OK"
|
||||
|
||||
inner class Inner {
|
||||
fun foo() = result
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val f = Outer.Inner::foo
|
||||
return Outer().Inner().f()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun box(): String {
|
||||
var result = "Fail"
|
||||
|
||||
fun changeToOK() { result = "OK" }
|
||||
|
||||
val ok = ::changeToOK
|
||||
ok()
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fun box(): String {
|
||||
val result = "OK"
|
||||
|
||||
class Local {
|
||||
fun foo() = result
|
||||
}
|
||||
|
||||
val member = Local::foo
|
||||
val instance = Local()
|
||||
return instance.member()
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun foo(until: Int): String {
|
||||
fun bar(x: Int): String =
|
||||
if (x == until) "OK" else bar(x + 1)
|
||||
return (::bar)(0)
|
||||
}
|
||||
|
||||
fun box() = foo(10)
|
||||
@@ -0,0 +1,7 @@
|
||||
fun box(): String {
|
||||
val result = "OK"
|
||||
|
||||
fun foo() = result
|
||||
|
||||
return (::foo)()
|
||||
}
|
||||
Reference in New Issue
Block a user