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>
71 lines
1.6 KiB
Kotlin
Vendored
71 lines
1.6 KiB
Kotlin
Vendored
// WITH_STDLIB
|
|
// FILE: test.kt
|
|
|
|
enum class E() {
|
|
A,
|
|
B;
|
|
|
|
fun foo() = {
|
|
prop
|
|
}
|
|
|
|
val prop = 22
|
|
}
|
|
|
|
enum class E2(val y : Int) {
|
|
C(1),
|
|
D(
|
|
2
|
|
)
|
|
}
|
|
|
|
fun box() {
|
|
E.A.foo()
|
|
E2.C;
|
|
}
|
|
|
|
// JVM_IR maintains line number information in the class initializer for the
|
|
// initialization of the enum entries. There is line number information for
|
|
// the allocation of the object, for the evaluation of arguments to the
|
|
// constructor, and for the call to the constructor. This is consistent
|
|
// with the line number information generated for normal object allocation.
|
|
|
|
// JVM has no line number information in <clinit> if there are no arguments
|
|
// to the enum constructor. If there are arguments it has line number information
|
|
// for the evaluation of the arguments constructor and for the constructor call,
|
|
// but not for the allocation of the object.
|
|
|
|
// EXPECTATIONS JVM JVM_IR
|
|
// test.kt:23 box
|
|
// EXPECTATIONS JVM_IR
|
|
// test.kt:5 <clinit>
|
|
// test.kt:6 <clinit>
|
|
// EXPECTATIONS JVM JVM_IR
|
|
// test.kt:8 foo
|
|
// test.kt:10 foo
|
|
// test.kt:23 box
|
|
// test.kt:24 box
|
|
// test.kt:16 <clinit>
|
|
// EXPECTATIONS JVM_IR
|
|
// test.kt:17 <clinit>
|
|
// EXPECTATIONS JVM JVM_IR
|
|
// test.kt:18 <clinit>
|
|
// test.kt:17 <clinit>
|
|
// test.kt:25 box
|
|
|
|
// EXPECTATIONS JS_IR
|
|
// test.kt:23 box
|
|
// test.kt:12 <init>
|
|
// test.kt:4 <init>
|
|
// test.kt:12 <init>
|
|
// test.kt:4 <init>
|
|
// test.kt:23 box
|
|
// test.kt:10 foo
|
|
// test.kt:8 E$foo$lambda
|
|
// test.kt:16 E2_initEntries
|
|
// test.kt:15 <init>
|
|
// test.kt:15 <init>
|
|
// test.kt:18 E2_initEntries
|
|
// test.kt:15 <init>
|
|
// test.kt:15 <init>
|
|
// test.kt:25 box |