mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
Initialization of companion object members (e.g., delegate properties using provideDelegate convention) can depend on property metadata array, which in turn can be initialized before other class members. #KT-18902 Fixed Target versions 1.1.5
21 lines
385 B
Kotlin
Vendored
21 lines
385 B
Kotlin
Vendored
import kotlin.reflect.KProperty
|
|
|
|
class Delegate {
|
|
operator fun getValue(thisRef: Test, property: KProperty<*>) = "OK"
|
|
}
|
|
|
|
class Provider {
|
|
operator fun provideDelegate(thisRef: Test, property: KProperty<*>) = Delegate()
|
|
}
|
|
|
|
class Test {
|
|
companion object {
|
|
val instance = Test()
|
|
}
|
|
|
|
val message by Provider()
|
|
}
|
|
|
|
val x = Test.instance.message
|
|
|
|
// expected: x: OK |