mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +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
23 lines
386 B
Kotlin
Vendored
23 lines
386 B
Kotlin
Vendored
// LANGUAGE_VERSION: 1.2
|
|
|
|
enum class A {
|
|
X {
|
|
val k = "K"
|
|
|
|
val anonObject = object {
|
|
inner class Inner {
|
|
val x = "O" + k
|
|
}
|
|
|
|
val innerX = Inner().x
|
|
|
|
override fun toString() = innerX
|
|
}
|
|
|
|
override val test = anonObject.toString()
|
|
};
|
|
|
|
abstract val test: String
|
|
}
|
|
|
|
fun box() = A.X.test |