Fix enum entry reference from enum entry initialization context

Enum entries are "special" kind of singletons that should be
referenced as a captured 'this' instance inside during entry
initialization, because corresponding static fields in enum class
are not initialized yet.

 #KT-7257 Fixed
This commit is contained in:
Dmitry Petrov
2017-09-11 11:42:53 +03:00
parent 40e2046e76
commit 6b6d1e80f8
19 changed files with 601 additions and 14 deletions
@@ -0,0 +1,21 @@
// LANGUAGE_VERSION: 1.2
enum class X {
B {
val k = "K"
inner class Inner {
fun foo() = "O" + k
}
val inner = Inner()
val bmr = inner::foo
override val value = bmr.invoke()
};
abstract val value: String
}
fun box() = X.B.value