Files
kotlin-fork/compiler/testData/codegen/box/reflection/noReflectAtRuntime/methodsFromAny/delegatedProperty.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

32 lines
700 B
Kotlin
Vendored

// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// IGNORE_BACKEND: JS
// IGNORE_BACKEND: NATIVE
// WITH_STDLIB
import kotlin.reflect.KProperty
import kotlin.test.assertEquals
object Delegate {
lateinit var prop: KProperty<*>
operator fun provideDelegate(thiz: Any?, p: KProperty<*>): Delegate {
prop = p
return this
}
operator fun getValue(x: Any?, p: KProperty<*>) {
assertEquals(prop as Any, p)
assertEquals(p as Any, prop)
assertEquals(p.hashCode(), prop.hashCode())
assertEquals("property x (Kotlin reflection is not available)", p.toString())
}
}
val x: Unit by Delegate
fun box(): String {
x
return "OK"
}