mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 08:31:26 +00:00
21 lines
306 B
Kotlin
Vendored
21 lines
306 B
Kotlin
Vendored
import kotlin.reflect.KProperty
|
|
|
|
class Delegate {
|
|
operator fun getValue(t: F.A, p: KProperty<*>): Int = 1
|
|
}
|
|
|
|
class F {
|
|
val A.prop: Int by Delegate()
|
|
|
|
class A {
|
|
}
|
|
|
|
fun foo(): Int {
|
|
return A().prop
|
|
}
|
|
}
|
|
|
|
fun box(): String {
|
|
return if(F().foo() == 1) "OK" else "fail"
|
|
}
|