Files
kotlin-fork/compiler/testData/codegen/box/enum/enumCompanionInit.kt
T
Mikhail Glukhikh a4c7619c89 [FIR2IR] Introduce & use FirBuiltInsPackageFragment
Without this commit, JVM name mapping logic in BE does not work for FIR,
because FIR cannot use old BuiltInsPackageFragmentImpl descriptor.
In this commit we add our own implementation thus fixing
a pack of FIR black box tests.
2020-03-24 10:37:53 +03:00

48 lines
836 B
Kotlin
Vendored

// IGNORE_BACKEND: JS_IR
// IGNORE_BACKEND: NATIVE
var result = ""
enum class E(a: String) {
X("x"),
Y("y");
init {
result += "E.init($a);"
}
companion object {
init {
result += "E.companion.init;"
val value = E.values()[0].name
result += "$value;"
}
}
}
enum class F(a: String) {
X("x"),
Y("y");
init {
result += "F.init($a);"
}
companion object {
init {
result += "F.companion.init;"
}
fun foo() {
result += "F.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"
return "OK"
}