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:
@@ -0,0 +1,19 @@
|
||||
// LANGUAGE_VERSION: 1.2
|
||||
|
||||
enum class A {
|
||||
X {
|
||||
val x = "OK"
|
||||
|
||||
inner class Inner {
|
||||
fun foo() = this@X.x
|
||||
}
|
||||
|
||||
val z = Inner()
|
||||
|
||||
override val test = z.foo()
|
||||
};
|
||||
|
||||
abstract val test: String
|
||||
}
|
||||
|
||||
fun box() = A.X.test
|
||||
Reference in New Issue
Block a user