[FIR] KT-55840: Ensure everything actually works

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>
This commit is contained in:
Nikolay Lunyak
2023-02-10 16:57:51 +00:00
committed by Space Team
parent 57eae167cc
commit a9343aeb7d
207 changed files with 280 additions and 223 deletions
+28 -27
View File
@@ -1,3 +1,4 @@
// WITH_STDLIB
// FILE: test.kt
enum class E() {
@@ -35,36 +36,36 @@ fun box() {
// but not for the allocation of the object.
// EXPECTATIONS JVM JVM_IR
// test.kt:22 box
// EXPECTATIONS JVM_IR
// test.kt:4 <clinit>
// test.kt:5 <clinit>
// EXPECTATIONS JVM JVM_IR
// test.kt:7 foo
// test.kt:9 foo
// test.kt:22 box
// test.kt:23 box
// test.kt:15 <clinit>
// EXPECTATIONS JVM_IR
// test.kt:16 <clinit>
// test.kt:5 <clinit>
// test.kt:6 <clinit>
// EXPECTATIONS JVM JVM_IR
// test.kt:17 <clinit>
// test.kt:16 <clinit>
// 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:22 box
// test.kt:11 <init>
// test.kt:3 <init>
// test.kt:11 <init>
// test.kt:3 <init>
// test.kt:22 box
// test.kt:9 foo
// test.kt:7 E$foo$lambda
// test.kt:15 E2_initEntries
// test.kt:14 <init>
// test.kt:14 <init>
// test.kt:17 E2_initEntries
// test.kt:14 <init>
// test.kt:14 <init>
// test.kt:24 box
// 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