a9343aeb7d
This inconsistency is present due to not using the `// WITH_STDLIB` in the above tests. When K1 creates the enum, it tries to generate `entries()`, and for that it tries to load `kotlin.enums.EnumEntries`, but this is actually an unresolved reference. K1 silently swallows it, and proceeds. The reason K2 doesn't fail is that in order to generate `entries()` it simply creates the necessary `ConeClassLikeType` with the desired `classId` instead of loading the whole `ClassDescriptor`. The reason we can still observe `$ENTRIES` and `$entries` in K1 is because they are generated during the JVM codegen, and it only checks if the `EnumEntries` language feature is supported. It doesn't check if the `entries` property has really existed in IR (by this time it's expected to have already been lowered to the `get-entries` function - that's why "has ... existed"). The reason why the codegen doesn't fail when working with `kotlin.enums.EnumEntries` is because it creates its own `IrClassSymbol`. ^KT-55840 Fixed Merge-request: KT-MR-8727 Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
74 lines
1.2 KiB
Kotlin
Vendored
74 lines
1.2 KiB
Kotlin
Vendored
// WITH_STDLIB
|
|
// 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 = ""
|
|
|
|
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;"
|
|
}
|
|
}
|
|
}
|
|
|
|
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()
|
|
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"
|
|
}
|