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>
66 lines
1.4 KiB
Kotlin
Vendored
66 lines
1.4 KiB
Kotlin
Vendored
// WITH_STDLIB
|
|
// IGNORE_BACKEND_K2: JS_IR, NATIVE
|
|
|
|
enum class A1(val prop1: String) {
|
|
X("asd"),
|
|
Y() {
|
|
override fun f() = super.f() + "#Y"
|
|
},
|
|
Z(5);
|
|
|
|
val prop2: String = "const2"
|
|
var prop3: String = ""
|
|
|
|
constructor(): this("default") {
|
|
prop3 = "empty"
|
|
}
|
|
constructor(x: Int): this(x.toString()) {
|
|
prop3 = "int"
|
|
}
|
|
|
|
open fun f(): String = "$prop1#$prop2#$prop3"
|
|
}
|
|
|
|
enum class A2 {
|
|
X("asd"),
|
|
Y() {
|
|
override fun f() = super.f() + "#Y"
|
|
},
|
|
Z(5);
|
|
|
|
val prop1: String
|
|
val prop2: String = "const2"
|
|
var prop3: String = ""
|
|
|
|
constructor(arg: String) {
|
|
prop1 = arg
|
|
}
|
|
constructor() {
|
|
prop1 = "default"
|
|
prop3 = "empty"
|
|
}
|
|
constructor(x: Int): this(x.toString()) {
|
|
prop3 = "int"
|
|
}
|
|
|
|
open fun f(): String = "$prop1#$prop2#$prop3"
|
|
}
|
|
|
|
fun box(): String {
|
|
val a1x = A1.X
|
|
if (a1x.f() != "asd#const2#") return "fail1: ${a1x.f()}"
|
|
val a1y = A1.Y
|
|
if (a1y.f() != "default#const2#empty#Y") return "fail2: ${a1y.f()}"
|
|
val a1z = A1.Z
|
|
if (a1z.f() != "5#const2#int") return "fail3: ${a1z.f()}"
|
|
|
|
val a2x = A2.X
|
|
if (a2x.f() != "asd#const2#") return "fail4: ${a2x.f()}"
|
|
val a2y = A2.Y
|
|
if (a2y.f() != "default#const2#empty#Y") return "fail5: ${a2y.f()}"
|
|
val a2z = A2.Z
|
|
if (a2z.f() != "5#const2#int") return "fail6: ${a2z.f()}"
|
|
|
|
return "OK"
|
|
}
|