Files
kotlin-fork/compiler/testData/codegen/box/reflection/noReflectAtRuntime/methodsFromAny/delegatedProperty.kt
T
Juan Chen 9dd8eda1c9 [FIR]: fix library methods in packages
Library methods such as 'listOf' are resolved
to have the package fragments as their parents,
but JVM expects their containing file classes as parents.
This fix generates those file classes and
uses them as parent replacements for such library methods.
2020-02-20 14:24:02 +03:00

31 lines
672 B
Kotlin
Vendored

// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS
// IGNORE_BACKEND: NATIVE
// WITH_RUNTIME
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"
}