Files
kotlin-fork/compiler/testData/codegen/box/delegatedProperty/capturePropertyInClosure.kt
T
2020-04-03 13:29:55 +03:00

24 lines
414 B
Kotlin
Vendored

import kotlin.reflect.KProperty
class Delegate {
var inner = 1
operator fun getValue(t: Any?, p: KProperty<*>): Int = inner
operator fun setValue(t: Any?, p: KProperty<*>, i: Int) { inner = i }
}
class B {
private var value: Int by Delegate()
public fun test() {
fun foo() {
value = 1
}
foo()
}
}
fun box(): String {
B().test()
return "OK"
}