Fir2Ir: more precise calculation of enum class modality

Use the same condition as in the already existing `createIrEnumEntry`
function (and as in psi2ir): enum class should be final unless there's
an enum entry with any declaration other than its constructor.

 #KT-57216
This commit is contained in:
Alexander Udalov
2023-03-15 00:11:36 +01:00
committed by Space Team
parent 2cc3b542fd
commit 68b94b07b8
17 changed files with 43 additions and 45 deletions
@@ -8,14 +8,14 @@ FILE fqName:<root> fileName:/temporaryInEnumEntryInitializer.kt
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-n> (): kotlin.Any? declared in <root>'
GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:n type:kotlin.Any? visibility:private [final,static]' type=kotlin.Any? origin=null
CLASS ENUM_CLASS name:En modality:OPEN visibility:public superTypes:[kotlin.Enum<<root>.En>]
CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.En>]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.En
CONSTRUCTOR visibility:private <> (x:kotlin.String?) returnType:<root>.En [primary]
VALUE_PARAMETER name:x index:0 type:kotlin.String?
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'public constructor <init> (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum'
<E>: <root>.En
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:OPEN visibility:public superTypes:[kotlin.Enum<<root>.En>]'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.En>]'
PROPERTY name:x visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String? visibility:private [final]
EXPRESSION_BODY
@@ -2,7 +2,7 @@ val n: Any?
field = null
get
open enum class En : Enum<En> {
enum class En : Enum<En> {
private constructor(x: String?) /* primary */ {
super/*Enum*/<En>()
/* <init>() */
@@ -29,3 +29,4 @@ open enum class En : Enum<En> {
get(): EnumEntries<En> /* Synthetic body for ENUM_ENTRIES */
}