mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-13 08:31:31 +00:00
22 lines
570 B
Kotlin
Vendored
22 lines
570 B
Kotlin
Vendored
//For KT-6020
|
|
import kotlin.reflect.KProperty1
|
|
import kotlin.reflect.KMutableProperty1
|
|
import kotlin.reflect.KProperty
|
|
|
|
class Value<T>(var value: T = null as T, var text: String? = null)
|
|
|
|
val <T> Value<T>.additionalText by DVal(Value<T>::text) //works
|
|
|
|
val <T> Value<T>.additionalValue by DVal(Value<T>::value) //not work
|
|
|
|
class DVal<T, R, P: KProperty1<T, R>>(val kmember: P) {
|
|
operator fun getValue(t: T, p: KProperty<*>): R {
|
|
return kmember.get(t)
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
val p = Value("O", "K")
|
|
return p.additionalValue + p.additionalText
|
|
}
|