Add additional tests for bound receivers in callable references

This commit is contained in:
Steven Schäfer
2019-08-15 16:02:30 +02:00
committed by max-kammerer
parent d89d68e3df
commit 62a1ea643a
8 changed files with 118 additions and 0 deletions
@@ -0,0 +1,14 @@
var x = 0
class A {
fun f() = if (x == 1) "OK" else "Fail $x"
}
fun callTwice(f: () -> String): String {
f()
return f()
}
fun box(): String {
return callTwice(({ x++; A() }())::f)
}
@@ -0,0 +1,18 @@
// WITH_REFLECT
import kotlin.reflect.KProperty0
var x = 0
class A {
val p: String
get() = if (x == 1) "OK" else "Fail $x"
}
fun callTwice(p: KProperty0<String>): String {
p.get()
return p.get()
}
fun box(): String {
return callTwice(({ x++; A() }())::p)
}