From d84067162055527506c7913914d323530d8f66fb Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 5 Dec 2019 12:30:49 +0300 Subject: [PATCH] [FIR] Don't create delegating super constructor call to `kotlin.Enum` for enums --- .../converter/DeclarationsConverter.kt | 10 ++-- .../kotlin/fir/builder/RawFirBuilder.kt | 30 +++++++----- .../rawBuilder/declarations/enums.txt | 4 +- .../rawBuilder/declarations/enums2.txt | 2 +- .../fir/resolve/testData/resolve/enum.txt | 2 +- .../testData/resolve/exhaustiveness_enum.txt | 2 +- .../resolve/expresssions/enumValues.txt | 2 +- .../expresssions/qualifiedExpressions.txt | 2 +- .../testData/resolve/fromBuilder/enums.txt | 4 +- .../ir/irText/classes/classes.fir.txt | 3 +- .../testData/ir/irText/classes/enum.fir.txt | 18 +++----- .../irText/classes/enumClassModality.fir.txt | 46 ++++++++++++------- .../classes/enumWithSecondaryCtor.fir.txt | 9 ++-- .../classesWithAnnotations.fir.txt | 3 +- .../enumEntriesWithAnnotations.fir.txt | 3 +- .../enumsInAnnotationArguments.fir.txt | 3 +- .../multiplatform/expectedEnumClass.fir.txt | 6 +-- .../expressions/enumEntryAsReceiver.fir.txt | 3 +- ...umEntryReferenceFromEnumEntryClass.fir.txt | 3 +- .../expressions/objectAsCallable.fir.txt | 3 +- .../temporaryInEnumEntryInitializer.fir.txt | 3 +- .../ir/irText/expressions/values.fir.txt | 3 +- .../ir/irText/singletons/enumEntry.fir.txt | 3 +- 23 files changed, 84 insertions(+), 83 deletions(-) diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index 6cfda8837ec..084237c34cf 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -387,9 +387,9 @@ class DeclarationsConverter( val selfType = null.toDelegatedSelfType(firClass) - val defaultDelegatedSuperTypeRef = when { - modifiers.isEnum() && (classKind == ClassKind.ENUM_CLASS) -> - FirResolvedTypeRefImpl( + when { + modifiers.isEnum() && (classKind == ClassKind.ENUM_CLASS) -> { + superTypeRefs += FirResolvedTypeRefImpl( source = null, ConeClassLikeTypeImpl( implicitEnumType.type.lookupTag, @@ -397,12 +397,12 @@ class DeclarationsConverter( isNullable = false ) ) + } modifiers.isAnnotation() && (classKind == ClassKind.ANNOTATION_CLASS) -> { superTypeRefs += implicitAnnotationType - implicitAnyType } - else -> implicitAnyType } + val defaultDelegatedSuperTypeRef = implicitAnyType superTypeRefs.ifEmpty { superTypeRefs += defaultDelegatedSuperTypeRef } diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 4f41704f848..938a5f41d6c 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.* +import org.jetbrains.kotlin.ir.expressions.IrConstKind import org.jetbrains.kotlin.lexer.KtTokens.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name @@ -343,22 +344,29 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder } } - val defaultDelegatedSuperTypeRef = when { - this is KtClass && classKind == ClassKind.ENUM_CLASS -> FirResolvedTypeRefImpl( - null, - ConeClassLikeTypeImpl( - implicitEnumType.type.lookupTag, - delegatedSelfTypeRef?.coneTypeUnsafe()?.let { arrayOf(it) } ?: emptyArray(), - isNullable = false + when { + this is KtClass && classKind == ClassKind.ENUM_CLASS -> { + /* + * kotlin.Enum constructor has (name: String, ordinal: Int) signature, + * so we should generate non-trivial constructors for enum and it's entry + * for correct resolve of super constructor call or just call kotlin.Any constructor + * and convert it to right call at backend, because of it doesn't affects frontend work + */ + container.superTypeRefs += FirResolvedTypeRefImpl( + null, + ConeClassLikeTypeImpl( + implicitEnumType.type.lookupTag, + delegatedSelfTypeRef?.coneTypeUnsafe()?.let { arrayOf(it) } ?: emptyArray(), + isNullable = false + ) ) - ) + } this is KtClass && classKind == ClassKind.ANNOTATION_CLASS -> { container.superTypeRefs += implicitAnnotationType - implicitAnyType } - else -> implicitAnyType } - // TODO: for enum / annotations, it *should* be empty + + val defaultDelegatedSuperTypeRef = implicitAnyType if (container.superTypeRefs.isEmpty()) { container.superTypeRefs += defaultDelegatedSuperTypeRef } diff --git a/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.txt b/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.txt index 8a53886ba74..2ea8aa1b2ec 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums.txt @@ -1,7 +1,7 @@ FILE: enums.kt public? final? enum class Order : R|kotlin/Enum| { private constructor(): R|Order| { - super|>() + super() } public? final enum entry FIRST : R|kotlin/Any| { @@ -34,7 +34,7 @@ FILE: enums.kt } public? final? enum class Planet : R|kotlin/Enum| { public? constructor(m: Double, r: Double): R|Planet| { - super|>() + super() } public? final? val m: Double = R|/m| diff --git a/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums2.txt b/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums2.txt index 9bd096dd0b8..08874233cd5 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums2.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/declarations/enums2.txt @@ -15,7 +15,7 @@ FILE: enums2.kt } public? final? enum class SomeEnum : R|kotlin/Enum| { public? constructor(x: Some): R|SomeEnum| { - super|>() + super() } public? final? val x: Some = R|/x| diff --git a/compiler/fir/resolve/testData/resolve/enum.txt b/compiler/fir/resolve/testData/resolve/enum.txt index 721f1992dd1..da37e08aa07 100644 --- a/compiler/fir/resolve/testData/resolve/enum.txt +++ b/compiler/fir/resolve/testData/resolve/enum.txt @@ -15,7 +15,7 @@ FILE: enum.kt } public final enum class SomeEnum : R|kotlin/Enum| { private constructor(x: R|Some|): R|SomeEnum| { - super|>() + super() } public final val x: R|Some| = R|/x| diff --git a/compiler/fir/resolve/testData/resolve/exhaustiveness_enum.txt b/compiler/fir/resolve/testData/resolve/exhaustiveness_enum.txt index f7271c30294..eba42512082 100644 --- a/compiler/fir/resolve/testData/resolve/exhaustiveness_enum.txt +++ b/compiler/fir/resolve/testData/resolve/exhaustiveness_enum.txt @@ -1,7 +1,7 @@ FILE: exhaustiveness_enum.kt public final enum class Enum : R|kotlin/Enum| { private constructor(): R|Enum| { - super|>() + super() } public final enum entry A : R|kotlin/Any| { diff --git a/compiler/fir/resolve/testData/resolve/expresssions/enumValues.txt b/compiler/fir/resolve/testData/resolve/expresssions/enumValues.txt index bccb5259ed2..20074e81a63 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/enumValues.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/enumValues.txt @@ -1,7 +1,7 @@ FILE: enumValues.kt public final enum class MyEnum : R|kotlin/Enum| { private constructor(): R|MyEnum| { - super|>() + super() } public final enum entry FIRST : R|kotlin/Any| { diff --git a/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt b/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt index 52414280a1d..87f9923057e 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/qualifiedExpressions.txt @@ -30,7 +30,7 @@ FILE: qualifiedExpressions.kt } public final enum class E : R|kotlin/Enum| { private constructor(): R|a/b/E| { - super|>() + super() } public final enum entry entry : R|kotlin/Any| { diff --git a/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt b/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt index 800a31a02a3..8c3c052a2f6 100644 --- a/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt +++ b/compiler/fir/resolve/testData/resolve/fromBuilder/enums.txt @@ -1,7 +1,7 @@ FILE: enums.kt public final enum class Order : R|kotlin/Enum| { private constructor(): R|Order| { - super|>() + super() } public final enum entry FIRST : R|kotlin/Any| { @@ -34,7 +34,7 @@ FILE: enums.kt } public final enum class Planet : R|kotlin/Enum| { private constructor(m: R|kotlin/Double|, r: R|kotlin/Double|): R|Planet| { - super|>() + super() } public final val m: R|kotlin/Double| = R|/m| diff --git a/compiler/testData/ir/irText/classes/classes.fir.txt b/compiler/testData/ir/irText/classes/classes.fir.txt index 06f81032c8f..07be829b821 100644 --- a/compiler/testData/ir/irText/classes/classes.fir.txt +++ b/compiler/testData/ir/irText/classes/classes.fir.txt @@ -72,8 +72,7 @@ FILE fqName: fileName:/classes.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnumClass CONSTRUCTOR visibility:private <> () returnType:.TestEnumClass [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnumClass modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnumClass>]' FUN name:values visibility:public modality:FINAL <> ($this:.TestEnumClass) returnType:kotlin.Array<.TestEnumClass> $this: VALUE_PARAMETER name: type:.TestEnumClass diff --git a/compiler/testData/ir/irText/classes/enum.fir.txt b/compiler/testData/ir/irText/classes/enum.fir.txt index bbf7e8f2f6c..4895b17bfc6 100644 --- a/compiler/testData/ir/irText/classes/enum.fir.txt +++ b/compiler/testData/ir/irText/classes/enum.fir.txt @@ -3,8 +3,7 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum1 CONSTRUCTOR visibility:private <> () returnType:.TestEnum1 [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum1 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum1>]' CLASS ENUM_ENTRY name:TEST1 modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum1.TEST1 @@ -90,8 +89,7 @@ FILE fqName: fileName:/enum.kt CONSTRUCTOR visibility:private <> (x:kotlin.Int) returnType:.TestEnum2 [primary] VALUE_PARAMETER name:x index:0 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum2 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum2>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] @@ -317,8 +315,7 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum3 CONSTRUCTOR visibility:private <> () returnType:.TestEnum3 [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum3 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum3>]' CLASS ENUM_ENTRY name:TEST modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum3.TEST @@ -392,8 +389,7 @@ FILE fqName: fileName:/enum.kt CONSTRUCTOR visibility:private <> (x:kotlin.Int) returnType:.TestEnum4 [primary] VALUE_PARAMETER name:x index:0 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum4 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum4>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] @@ -593,8 +589,7 @@ FILE fqName: fileName:/enum.kt EXPRESSION_BODY CONST Int type=kotlin.Int value=0 BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum5 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum5>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] @@ -788,8 +783,7 @@ FILE fqName: fileName:/enum.kt VALUE_PARAMETER name:x index:0 type:kotlin.Int VALUE_PARAMETER name:y index:1 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum6 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum6>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] diff --git a/compiler/testData/ir/irText/classes/enumClassModality.fir.txt b/compiler/testData/ir/irText/classes/enumClassModality.fir.txt index 2c43737e673..4f0e2b71633 100644 --- a/compiler/testData/ir/irText/classes/enumClassModality.fir.txt +++ b/compiler/testData/ir/irText/classes/enumClassModality.fir.txt @@ -3,8 +3,7 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestFinalEnum1 CONSTRUCTOR visibility:private <> () returnType:.TestFinalEnum1 [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestFinalEnum1 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestFinalEnum1>]' CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestFinalEnum1.X1 @@ -71,8 +70,7 @@ FILE fqName: fileName:/enumClassModality.kt CONSTRUCTOR visibility:private <> (x:kotlin.Int) returnType:.TestFinalEnum2 [primary] VALUE_PARAMETER name:x index:0 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestFinalEnum2 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestFinalEnum2>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] @@ -186,8 +184,7 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestFinalEnum3 CONSTRUCTOR visibility:private <> () returnType:.TestFinalEnum3 [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestFinalEnum3 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestFinalEnum3>]' CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestFinalEnum3.X1 @@ -256,8 +253,7 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestOpenEnum1 CONSTRUCTOR visibility:private <> () returnType:.TestOpenEnum1 [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestOpenEnum1 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestOpenEnum1>]' CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestOpenEnum1.X1 @@ -324,8 +320,7 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestOpenEnum2 CONSTRUCTOR visibility:private <> () returnType:.TestOpenEnum2 [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestOpenEnum2 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestOpenEnum2>]' CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestOpenEnum2.X1 @@ -397,8 +392,7 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAbstractEnum1 CONSTRUCTOR visibility:private <> () returnType:.TestAbstractEnum1 [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestAbstractEnum1 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestAbstractEnum1>]' CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAbstractEnum1.X1 @@ -482,13 +476,12 @@ FILE fqName: fileName:/enumClassModality.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any - CLASS ENUM_CLASS name:TestAbstractEnum2 modality:FINAL visibility:public superTypes:[.IFoo] + CLASS ENUM_CLASS name:TestAbstractEnum2 modality:FINAL visibility:public superTypes:[.IFoo; kotlin.Enum<.TestAbstractEnum2>] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAbstractEnum2 CONSTRUCTOR visibility:private <> () returnType:.TestAbstractEnum2 [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : - INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestAbstractEnum2 modality:FINAL visibility:public superTypes:[.IFoo]' + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestAbstractEnum2 modality:FINAL visibility:public superTypes:[.IFoo; kotlin.Enum<.TestAbstractEnum2>]' CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAbstractEnum2.X1 CONSTRUCTOR visibility:public <> () returnType:.TestAbstractEnum2.X1 [primary] @@ -535,3 +528,24 @@ FILE fqName: fileName:/enumClassModality.kt overridden: public open fun toString (): kotlin.String declared in kotlin.Any $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum) returnType:kotlin.Any [fake_override] + overridden: + protected final fun clone (): kotlin.Any declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum, other:.TestAbstractEnum2) returnType:kotlin.Int [fake_override,operator] + overridden: + public final fun compareTo (other: E of kotlin.Enum): kotlin.Int [operator] declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum + VALUE_PARAMETER name:other index:0 type:.TestAbstractEnum2 + PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.TestAbstractEnum2) returnType:kotlin.String [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:.TestAbstractEnum2 + PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:.TestAbstractEnum2) returnType:kotlin.Int [fake_override] + correspondingProperty: PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + overridden: + public final fun (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:.TestAbstractEnum2 diff --git a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt index 25583fcf673..75a13472b73 100644 --- a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt +++ b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.fir.txt @@ -4,8 +4,7 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt CONSTRUCTOR visibility:private <> (x:kotlin.Int) returnType:.Test0 [primary] VALUE_PARAMETER name:x index:0 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Test0 modality:FINAL visibility:public superTypes:[kotlin.Enum<.Test0>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] @@ -87,8 +86,7 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt CONSTRUCTOR visibility:private <> (x:kotlin.Int) returnType:.Test1 [primary] VALUE_PARAMETER name:x index:0 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Test1 modality:FINAL visibility:public superTypes:[kotlin.Enum<.Test1>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] @@ -226,8 +224,7 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt CONSTRUCTOR visibility:private <> (x:kotlin.Int) returnType:.Test2 [primary] VALUE_PARAMETER name:x index:0 type:kotlin.Int BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Test2 modality:FINAL visibility:public superTypes:[kotlin.Enum<.Test2>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final] diff --git a/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.fir.txt index 91b02496ebc..c466a09dfcd 100644 --- a/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/classesWithAnnotations.fir.txt @@ -132,8 +132,7 @@ FILE fqName: fileName:/classesWithAnnotations.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum CONSTRUCTOR visibility:private <> () returnType:.TestEnum [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum>]' FUN name:values visibility:public modality:FINAL <> ($this:.TestEnum) returnType:kotlin.Array<.TestEnum> $this: VALUE_PARAMETER name: type:.TestEnum diff --git a/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.fir.txt b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.fir.txt index 2ef1d8777da..a2afb1a0181 100644 --- a/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.fir.txt @@ -31,8 +31,7 @@ FILE fqName: fileName:/enumEntriesWithAnnotations.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum CONSTRUCTOR visibility:private <> () returnType:.TestEnum [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum>]' CLASS ENUM_ENTRY name:ENTRY1 modality:FINAL visibility:public superTypes:[kotlin.Any] annotations: diff --git a/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt index 7b3a75002ed..a75a58f2bf9 100644 --- a/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt +++ b/compiler/testData/ir/irText/declarations/annotations/enumsInAnnotationArguments.fir.txt @@ -3,8 +3,7 @@ FILE fqName: fileName:/enumsInAnnotationArguments.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En CONSTRUCTOR visibility:private <> () returnType:.En [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>]' CLASS ENUM_ENTRY name:A modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En.A diff --git a/compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.fir.txt b/compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.fir.txt index 7b75c6f79e0..0833c282c68 100644 --- a/compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.fir.txt +++ b/compiler/testData/ir/irText/declarations/multiplatform/expectedEnumClass.fir.txt @@ -3,8 +3,7 @@ FILE fqName: fileName:/expectedEnumClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum CONSTRUCTOR visibility:private <> () returnType:.MyEnum [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public [expect] superTypes:[kotlin.Enum<.MyEnum>]' CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.FOO @@ -89,8 +88,7 @@ FILE fqName: fileName:/expectedEnumClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum CONSTRUCTOR visibility:private <> () returnType:.MyEnum [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public superTypes:[kotlin.Enum<.MyEnum>]' CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.FOO diff --git a/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt b/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt index c66555f8cc5..75eefe439a9 100644 --- a/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt +++ b/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.fir.txt @@ -3,8 +3,7 @@ FILE fqName: fileName:/enumEntryAsReceiver.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.X CONSTRUCTOR visibility:private <> () returnType:.X [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:X modality:FINAL visibility:public superTypes:[kotlin.Enum<.X>]' CLASS ENUM_ENTRY name:B modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.X.B diff --git a/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt b/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt index 8bba9b181d2..20a03446546 100644 --- a/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt +++ b/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.fir.txt @@ -3,8 +3,7 @@ FILE fqName: fileName:/enumEntryReferenceFromEnumEntryClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum CONSTRUCTOR visibility:private <> () returnType:.MyEnum [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public superTypes:[kotlin.Enum<.MyEnum>]' CLASS ENUM_ENTRY name:Z modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.Z diff --git a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt index f11930ee1dd..5d7ba410c29 100644 --- a/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt +++ b/compiler/testData/ir/irText/expressions/objectAsCallable.fir.txt @@ -22,8 +22,7 @@ FILE fqName: fileName:/objectAsCallable.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En CONSTRUCTOR visibility:private <> () returnType:.En [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>]' CLASS ENUM_ENTRY name:X modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.En.X diff --git a/compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.fir.txt b/compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.fir.txt index 7ecaf929170..f256f0abbc5 100644 --- a/compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.fir.txt +++ b/compiler/testData/ir/irText/expressions/temporaryInEnumEntryInitializer.fir.txt @@ -13,8 +13,7 @@ FILE fqName: fileName:/temporaryInEnumEntryInitializer.kt CONSTRUCTOR visibility:private <> (x:kotlin.String?) returnType:.En [primary] VALUE_PARAMETER name:x index:0 type:kotlin.String? BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<.En>]' PROPERTY name:x visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.String? visibility:private [final] diff --git a/compiler/testData/ir/irText/expressions/values.fir.txt b/compiler/testData/ir/irText/expressions/values.fir.txt index 5856ced9f1f..e77d6648048 100644 --- a/compiler/testData/ir/irText/expressions/values.fir.txt +++ b/compiler/testData/ir/irText/expressions/values.fir.txt @@ -3,8 +3,7 @@ FILE fqName: fileName:/values.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Enum CONSTRUCTOR visibility:private <> () returnType:.Enum [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Enum modality:FINAL visibility:public superTypes:[kotlin.Enum<.Enum>]' CLASS ENUM_ENTRY name:A modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Enum.A diff --git a/compiler/testData/ir/irText/singletons/enumEntry.fir.txt b/compiler/testData/ir/irText/singletons/enumEntry.fir.txt index c74e9565a06..6b739a659d0 100644 --- a/compiler/testData/ir/irText/singletons/enumEntry.fir.txt +++ b/compiler/testData/ir/irText/singletons/enumEntry.fir.txt @@ -3,8 +3,7 @@ FILE fqName: fileName:/enumEntry.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z CONSTRUCTOR visibility:private <> () returnType:.Z [primary] BLOCK_BODY - DELEGATING_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' - : + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Z modality:FINAL visibility:public superTypes:[kotlin.Enum<.Z>]' CLASS ENUM_ENTRY name:ENTRY modality:FINAL visibility:public superTypes:[kotlin.Any] $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z.ENTRY