mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-12 08:31:28 +00:00
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
17 lines
265 B
Kotlin
Vendored
17 lines
265 B
Kotlin
Vendored
enum class X {
|
|
B {
|
|
val value2 = "K"
|
|
|
|
val value3: String
|
|
init {
|
|
fun foo() = value2
|
|
value3 = "O" + foo()
|
|
}
|
|
|
|
override val value = value3
|
|
};
|
|
|
|
abstract val value: String
|
|
}
|
|
|
|
fun box() = X.B.value |