Files
kotlin-fork/compiler/testData/codegen/box/reflection/properties/localDelegated/localAndNonLocal.kt
T
2019-11-19 11:00:09 +03:00

36 lines
677 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// 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()
}