Files
kotlin/compiler/testData/codegen/boxWithStdlib/callableReference/property/genericProperty.kt
Alexander Udalov 30794060a9 Simplify property hierarchy in reflection
Leave only 3*2 = 6 classes: KProperty0, KProperty1, KProperty2 and their
mutable analogs, depending on the number of receivers a property takes
2015-07-10 20:10:09 +03:00

21 lines
528 B
Kotlin
Vendored

//For KT-6020
import kotlin.reflect.KProperty1
import kotlin.reflect.KMutableProperty1
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) {
fun get(t: T, p: PropertyMetadata): R {
return kmember.get(t)
}
}
fun box(): String {
val p = Value("O", "K")
return p.additionalValue + p.additionalText
}