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>
30 lines
622 B
Kotlin
Vendored
30 lines
622 B
Kotlin
Vendored
// WITH_STDLIB
|
|
interface A<T> {
|
|
open fun foo(t: T) = "A"
|
|
}
|
|
|
|
interface B : A<String>
|
|
|
|
enum class Z(val aname: String) : B {
|
|
Z1("Z1"),
|
|
Z2("Z2");
|
|
override fun foo(t: String) = aname
|
|
}
|
|
|
|
|
|
fun box(): String {
|
|
val z1b: B = Z.Z1
|
|
val z2b: B = Z.Z2
|
|
val z1a: A<String> = Z.Z1
|
|
val z2a: A<String> = Z.Z2
|
|
return when {
|
|
Z.Z1.foo("") != "Z1" -> "Fail #1"
|
|
Z.Z2.foo("") != "Z2" -> "Fail #2"
|
|
z1b.foo("") != "Z1" -> "Fail #3"
|
|
z2b.foo("") != "Z2" -> "Fail #4"
|
|
z1a.foo("") != "Z1" -> "Fail #5"
|
|
z2a.foo("") != "Z2" -> "Fail #6"
|
|
else -> "OK"
|
|
}
|
|
}
|