Inline get/setValues for local delegated properties

This commit is contained in:
Mikhael Bogdanov
2016-06-14 13:03:14 +03:00
parent 6f761d4e7d
commit 679f53b449
12 changed files with 144 additions and 95 deletions
@@ -0,0 +1,14 @@
package foo
import kotlin.reflect.KProperty
inline fun <T> run(f: () -> T) = f()
class Delegate {
operator fun getValue(t: Any?, p: KProperty<*>): Int = 1
}
fun box(): String {
val prop: Int by Delegate()
return run { if (prop == 1) "OK" else "fail" }
}