[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
+4
View File
@@ -16,6 +16,7 @@ public final enum class SimpleEnum {
private synthetic final static method $values(): SimpleEnum[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static @org.jetbrains.annotations.NotNull method getEntries(): kotlin.enums.EnumEntries
public static method valueOf(p0: java.lang.String): SimpleEnum
public static method values(): SimpleEnum[]
}
@@ -31,6 +32,7 @@ public final enum class WithAnnotations {
private synthetic final static method $values(): WithAnnotations[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int): void
public static @org.jetbrains.annotations.NotNull method getEntries(): kotlin.enums.EnumEntries
public static method valueOf(p0: java.lang.String): WithAnnotations
public static method values(): WithAnnotations[]
}
@@ -48,6 +50,7 @@ public final enum class WithConstructor {
private synthetic final static method $values(): WithConstructor[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int, p2: java.lang.String): void
public static @org.jetbrains.annotations.NotNull method getEntries(): kotlin.enums.EnumEntries
public final @org.jetbrains.annotations.NotNull method getX(): java.lang.String
public static method valueOf(p0: java.lang.String): WithConstructor
public static method values(): WithConstructor[]
@@ -74,6 +77,7 @@ public abstract enum class WithEntryClass {
private method <init>(p0: java.lang.String, p1: int): void
public synthetic method <init>(p0: java.lang.String, p1: int, p2: kotlin.jvm.internal.DefaultConstructorMarker): void
public abstract method foo(): void
public static @org.jetbrains.annotations.NotNull method getEntries(): kotlin.enums.EnumEntries
public static method valueOf(p0: java.lang.String): WithEntryClass
public static method values(): WithEntryClass[]
}
+1
View File
@@ -1,3 +1,4 @@
// WITH_STDLIB
enum class SimpleEnum {
A, B, C
}
@@ -38,6 +38,7 @@ public final enum class TestEnum {
private synthetic final static method $values(): TestEnum[]
static method <clinit>(): void
private method <init>(p0: java.lang.String, p1: int, p2: int): void
public static @org.jetbrains.annotations.NotNull method getEntries(): kotlin.enums.EnumEntries
public final method getZ-a_XrcN0(): int
public static method valueOf(p0: java.lang.String): TestEnum
public static method values(): TestEnum[]
@@ -1,3 +1,4 @@
// WITH_STDLIB
// !LANGUAGE: +InlineClasses
inline class Z(val x: Int)
@@ -11,6 +11,7 @@ public final enum class A$B$C {
private method <init>(p0: java.lang.String, p1: int): void
public static method values(): A$B$C[]
public static method valueOf(p0: java.lang.String): A$B$C
public static @org.jetbrains.annotations.NotNull method getEntries(): kotlin.enums.EnumEntries
private synthetic final static method $values(): A$B$C[]
private synthetic final static method $entries(): A$B$C[]
static method <clinit>(): void
+1
View File
@@ -1,3 +1,4 @@
// WITH_STDLIB
// DONT_SORT_DECLARATIONS
class Main {