[JS IR & WASM] Fix executing init blocks for enums with nested objects

This commit is contained in:
Sergej Jaskiewicz
2021-10-13 17:06:32 +03:00
committed by Space
parent 8e0e2fe52c
commit 9e5520bba8
11 changed files with 164 additions and 34 deletions
+27 -6
View File
@@ -1,7 +1,7 @@
// IGNORE_BACKEND: WASM
// WASM_MUTE_REASON: IGNORED_IN_JS
// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: JS_IR_ES6
// DONT_TARGET_EXACT_BACKEND: JS
// DONT_TARGET_EXACT_BACKEND: JS_IR
// DONT_TARGET_EXACT_BACKEND: JS_IR_ES6
// DONT_TARGET_EXACT_BACKEND: WASM
// IGNORE_BACKEND: NATIVE
var result = ""
@@ -41,11 +41,32 @@ enum class F(a: String) {
}
}
enum class G(a: String) {
X("x"),
Y("y");
init {
result += "G.init($a);"
}
object O {
init {
result += "G.O.init;"
}
fun foo() {
result += "G.O.foo();$X;"
}
}
}
fun box(): String {
val y = E.Y
result += "${y.name};"
F.foo()
if (result != "E.init(x);E.init(y);E.companion.init;X;Y;F.init(x);F.init(y);F.companion.init;F.foo();X;") return "fail: $result"
G.O.foo()
if (result != "E.init(x);E.init(y);E.companion.init;X;Y;F.init(x);F.init(y);F.companion.init;F.foo();X;G.O.init;G.O.foo();X;")
return "fail: $result"
return "OK"
}
}