Files
kotlin-fork/compiler/testData/codegen/box/classes/classObjectAsStaticInitializer.kt
T
Shagen Ogandzhanian 2d0535a713 [JS_IR] Invoke companion init block while instantiating a class
KT-40740, squashed rr/shagen/KT-40740-static-init-js-ir
2020-10-30 16:19:13 +01:00

29 lines
381 B
Kotlin
Vendored

// IGNORE_BACKEND: NATIVE
var global = "A"
class C {
init {
global += "D"
}
companion object {
init {
global += "B"
}
init {
global += "C"
}
}
}
fun box(): String {
if (global != "A") {
return "fail1: global = $global"
}
val c = C()
if (global == "ABCD") return "OK" else return "fail2: global = $global"
}