Files
kotlin-fork/compiler/testData/codegen/box/reflection/properties/localDelegated/localAndNonLocal.kt
T
pyos aa58ed9234 JVM_IR: partially implement FIR local delegated property reflection
Type parameter references are broken, just like for lambdas. Also, the
code is super ugly.
2020-09-22 09:35:45 +03:00

35 lines
647 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_REFLECT
import kotlin.reflect.KProperty
object Delegate {
operator fun getValue(thiz: Any?, property: KProperty<*>): String {
return property.name + ":" + property.returnType
}
}
class C {
val a by Delegate
fun test(): String {
if (a != "a:kotlin.String") return "Fail a: $a"
val b by Delegate
if (b != "b:kotlin.String") return "Fail b: $b"
return "OK"
}
}
val x by Delegate
fun box(): String {
if (x != "x:kotlin.String") return "Fail x: $x"
val y by Delegate
if (y != "y:kotlin.String") return "Fail y: $y"
return C().test()
}