[FIR] Don't create initializers for simple enum entries

Usually FIR enum entry is initialized by anonymous object,
which is the container for all enum entry' declarations.
However, for simple enum entries there is no need of initializer at all.
This commit is contained in:
Mikhail Glukhikh
2020-02-20 11:08:34 +03:00
parent b1e9dbf994
commit 39bd97147f
39 changed files with 266 additions and 277 deletions
@@ -7,33 +7,17 @@ FILE fqName:<root> fileName:/enumsInAnnotationArguments.kt
<E>: <root>.En
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:En modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.En>]'
ENUM_ENTRY name:A
class: CLASS ENUM_ENTRY name:A modality:FINAL visibility:private superTypes:[<root>.En]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.En.A
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:A modality:FINAL visibility:private superTypes:[<root>.En]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
ENUM_ENTRY name:B
class: CLASS ENUM_ENTRY name:B modality:FINAL visibility:private superTypes:[<root>.En]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.En.B
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:B modality:FINAL visibility:private superTypes:[<root>.En]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
ENUM_ENTRY name:C
class: CLASS ENUM_ENTRY name:C modality:FINAL visibility:private superTypes:[<root>.En]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.En.C
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:C modality:FINAL visibility:private superTypes:[<root>.En]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
ENUM_ENTRY name:D
class: CLASS ENUM_ENTRY name:D modality:FINAL visibility:private superTypes:[<root>.En]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.En.D
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:D modality:FINAL visibility:private superTypes:[<root>.En]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.En'
FUN name:values visibility:public modality:FINAL <> ($this:<root>.En) returnType:kotlin.Array<<root>.En>
$this: VALUE_PARAMETER name:<this> type:<root>.En
BLOCK_BODY
@@ -7,19 +7,11 @@ FILE fqName:<root> fileName:/expectedEnumClass.kt
<E>: <root>.MyEnum
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public [expect] superTypes:[kotlin.Enum<<root>.MyEnum>]'
ENUM_ENTRY name:FOO
class: CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:private superTypes:[<root>.MyEnum]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyEnum.FOO
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:private superTypes:[<root>.MyEnum]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
ENUM_ENTRY name:BAR
class: CLASS ENUM_ENTRY name:BAR modality:FINAL visibility:private superTypes:[<root>.MyEnum]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyEnum.BAR
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:BAR modality:FINAL visibility:private superTypes:[<root>.MyEnum]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
FUN name:values visibility:public modality:FINAL <> ($this:<root>.MyEnum) returnType:kotlin.Array<<root>.MyEnum>
$this: VALUE_PARAMETER name:<this> type:<root>.MyEnum
BLOCK_BODY
@@ -69,26 +61,14 @@ FILE fqName:<root> fileName:/expectedEnumClass.kt
<E>: <root>.MyEnum
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:MyEnum modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.MyEnum>]'
ENUM_ENTRY name:FOO
class: CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:private superTypes:[<root>.MyEnum]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyEnum.FOO
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:FOO modality:FINAL visibility:private superTypes:[<root>.MyEnum]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
ENUM_ENTRY name:BAR
class: CLASS ENUM_ENTRY name:BAR modality:FINAL visibility:private superTypes:[<root>.MyEnum]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyEnum.BAR
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:BAR modality:FINAL visibility:private superTypes:[<root>.MyEnum]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
ENUM_ENTRY name:BAZ
class: CLASS ENUM_ENTRY name:BAZ modality:FINAL visibility:private superTypes:[<root>.MyEnum]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.MyEnum.BAZ
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:BAZ modality:FINAL visibility:private superTypes:[<root>.MyEnum]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.MyEnum'
FUN name:values visibility:public modality:FINAL <> ($this:<root>.MyEnum) returnType:kotlin.Array<<root>.MyEnum>
$this: VALUE_PARAMETER name:<this> type:<root>.MyEnum
BLOCK_BODY