[JS IR] Initialize enum fields before accessing them in companion object

see https://youtrack.jetbrains.com/issue/KT-43901
This commit is contained in:
Shagen Ogandzhanian
2020-12-18 01:54:01 +01:00
parent 3eb0745b58
commit 4f96f9d6a1
11 changed files with 92 additions and 14 deletions
@@ -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"
}