Use delegate initializer expression resolution scope for 'toDelegateFor' resolution.
This commit is contained in:
committed by
Stanislav Erokhin
parent
a6bc7271ae
commit
5ddf8e60e6
+16
@@ -0,0 +1,16 @@
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
var log = ""
|
||||
|
||||
class UserDataProperty<in R>(val key: String) {
|
||||
operator fun getValue(thisRef: R, desc: KProperty<*>) = thisRef.toString() + key
|
||||
|
||||
operator fun setValue(thisRef: R, desc: KProperty<*>, value: String?) { log += "set"}
|
||||
}
|
||||
|
||||
|
||||
var String.calc: String by UserDataProperty("K")
|
||||
|
||||
fun box(): String {
|
||||
return "O".calc
|
||||
}
|
||||
Reference in New Issue
Block a user