Initialize property metadata array before class body generation

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
This commit is contained in:
Dmitry Petrov
2017-07-10 15:44:50 +03:00
parent 8a9707c140
commit efb6756cbc
13 changed files with 99 additions and 9 deletions
@@ -0,0 +1,21 @@
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