[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
+4 -12
View File
@@ -7,19 +7,11 @@ FILE fqName:<root> fileName:/enum.kt
<E>: <root>.TestEnum1
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestEnum1 modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.TestEnum1>]'
ENUM_ENTRY name:TEST1
class: CLASS ENUM_ENTRY name:TEST1 modality:FINAL visibility:private superTypes:[<root>.TestEnum1]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.TestEnum1.TEST1
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.TestEnum1'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:TEST1 modality:FINAL visibility:private superTypes:[<root>.TestEnum1]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.TestEnum1'
ENUM_ENTRY name:TEST2
class: CLASS ENUM_ENTRY name:TEST2 modality:FINAL visibility:private superTypes:[<root>.TestEnum1]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.TestEnum1.TEST2
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.TestEnum1'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:TEST2 modality:FINAL visibility:private superTypes:[<root>.TestEnum1]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.TestEnum1'
FUN name:values visibility:public modality:FINAL <> ($this:<root>.TestEnum1) returnType:kotlin.Array<<root>.TestEnum1>
$this: VALUE_PARAMETER name:<this> type:<root>.TestEnum1
BLOCK_BODY
@@ -7,12 +7,8 @@ FILE fqName:<root> fileName:/enumClassModality.kt
<E>: <root>.TestFinalEnum1
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestFinalEnum1 modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.TestFinalEnum1>]'
ENUM_ENTRY name:X1
class: CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[<root>.TestFinalEnum1]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.TestFinalEnum1.X1
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.TestFinalEnum1'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[<root>.TestFinalEnum1]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.TestFinalEnum1'
FUN name:values visibility:public modality:FINAL <> ($this:<root>.TestFinalEnum1) returnType:kotlin.Array<<root>.TestFinalEnum1>
$this: VALUE_PARAMETER name:<this> type:<root>.TestFinalEnum1
BLOCK_BODY
@@ -130,12 +126,8 @@ FILE fqName:<root> fileName:/enumClassModality.kt
<E>: <root>.TestFinalEnum3
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:TestFinalEnum3 modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.TestFinalEnum3>]'
ENUM_ENTRY name:X1
class: CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[<root>.TestFinalEnum3]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.TestFinalEnum3.X1
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.TestFinalEnum3'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:private superTypes:[<root>.TestFinalEnum3]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.TestFinalEnum3'
FUN name:doStuff visibility:public modality:FINAL <> ($this:<root>.TestFinalEnum3) returnType:kotlin.Unit
$this: VALUE_PARAMETER name:<this> type:<root>.TestFinalEnum3
BLOCK_BODY
@@ -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
@@ -26,12 +26,8 @@ FILE fqName:<root> fileName:/objectAsCallable.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:X
class: CLASS ENUM_ENTRY name:X modality:FINAL visibility:private superTypes:[<root>.En]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.En.X
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:X 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
+2 -6
View File
@@ -7,12 +7,8 @@ FILE fqName:<root> fileName:/values.kt
<E>: <root>.Enum
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_CLASS name:Enum modality:FINAL visibility:public superTypes:[kotlin.Enum<<root>.Enum>]'
ENUM_ENTRY name:A
class: CLASS ENUM_ENTRY name:A modality:FINAL visibility:private superTypes:[<root>.Enum]
$this: VALUE_PARAMETER INSTANCE_RECEIVER name:<this> type:<root>.Enum.A
CONSTRUCTOR visibility:private <> () returnType:<uninitialized parent>.<anonymous> [primary]
BLOCK_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Enum'
INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:A modality:FINAL visibility:private superTypes:[<root>.Enum]'
init: EXPRESSION_BODY
ENUM_CONSTRUCTOR_CALL 'private constructor <init> () [primary] declared in <root>.Enum'
FUN name:values visibility:public modality:FINAL <> ($this:<root>.Enum) returnType:kotlin.Array<<root>.Enum>
$this: VALUE_PARAMETER name:<this> type:<root>.Enum
BLOCK_BODY