[JS IR] Initialize enum fields before accessing them in companion object
see https://youtrack.jetbrains.com/issue/KT-43901
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
private var logs = ""
|
||||
|
||||
enum class Foo(val text: String) {
|
||||
FOO("foo"),
|
||||
BAR("bar"),
|
||||
PING("foo");
|
||||
|
||||
init {
|
||||
logs += "${text}A;"
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
logs += "StatA;"
|
||||
}
|
||||
val first = values()[0]
|
||||
init {
|
||||
logs += "Stat${first.text};"
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
logs += "${text}B;"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
Foo.FOO
|
||||
|
||||
if (Foo.first !== Foo.FOO) return "FAIL 0: ${Foo.first}"
|
||||
|
||||
if (logs != "fooA;fooB;barA;barB;fooA;fooB;StatA;Statfoo;") return "FAIL 1: ${logs}"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user