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,18 @@
|
||||
enum class X {
|
||||
B {
|
||||
|
||||
override val value = "OK"
|
||||
|
||||
val bmr = B::value.get()
|
||||
|
||||
override fun foo(): String {
|
||||
return bmr
|
||||
}
|
||||
};
|
||||
|
||||
abstract val value: String
|
||||
|
||||
abstract fun foo(): String
|
||||
}
|
||||
|
||||
fun box() = X.B.foo()
|
||||
Reference in New Issue
Block a user