From 35c2573b3363a8a351d2ae000df9e14c96635a3e Mon Sep 17 00:00:00 2001 From: pyos Date: Fri, 15 Nov 2019 11:17:23 +0100 Subject: [PATCH] PSI2IR: generate IrEnumConstructorCalls with correct return type Normally, the fact that is was Unit was not visible as enum constructors are lowered to normal class constructors anyway. The exception is when the arguments are reordered, causing the incorrect return type to leak into the block that holds temporary variables. --- .../kotlin/psi2ir/generators/CallGenerator.kt | 5 +- .../box/enum/constructorWithReordering.kt | 10 ++ compiler/testData/ir/irText/classes/enum.kt | 8 +- compiler/testData/ir/irText/classes/enum.txt | 104 +++++++++++++++++- .../ir/irText/classes/enumClassModality.txt | 12 +- .../irText/classes/enumWithSecondaryCtor.txt | 8 +- .../enumEntriesWithAnnotations.txt | 3 +- .../expressions/enumEntryAsReceiver.txt | 3 +- .../enumEntryReferenceFromEnumEntryClass.txt | 3 +- .../ir/irText/singletons/enumEntry.txt | 3 +- .../codegen/BlackBoxCodegenTestGenerated.java | 5 + .../LightAnalysisModeTestGenerated.java | 5 + .../ir/FirBlackBoxCodegenTestGenerated.java | 5 + .../ir/IrBlackBoxCodegenTestGenerated.java | 5 + .../IrJsCodegenBoxTestGenerated.java | 5 + .../semantics/JsCodegenBoxTestGenerated.java | 5 + 16 files changed, 170 insertions(+), 19 deletions(-) create mode 100644 compiler/testData/codegen/box/enum/constructorWithReordering.kt diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt index 04c98cddfd5..56f546293b2 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt @@ -160,9 +160,10 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator if (dispatchReceiver != null) throw AssertionError("Dispatch receiver should be null: $dispatchReceiver") if (extensionReceiver != null) throw AssertionError("Extension receiver should be null: $extensionReceiver") val constructorSymbol = context.symbolTable.referenceConstructor(constructorDescriptor.original) - val irCall = IrEnumConstructorCallImpl(startOffset, endOffset, context.irBuiltIns.unitType, constructorSymbol) + val returnType = constructorDescriptor.returnType.toIrType() + val irCall = IrEnumConstructorCallImpl(startOffset, endOffset, returnType, constructorSymbol) context.callToSubstitutedDescriptorMap[irCall] = constructorDescriptor - addParametersToCall(startOffset, endOffset, call, irCall, context.irBuiltIns.unitType) + addParametersToCall(startOffset, endOffset, call, irCall, irCall.type) } } diff --git a/compiler/testData/codegen/box/enum/constructorWithReordering.kt b/compiler/testData/codegen/box/enum/constructorWithReordering.kt new file mode 100644 index 00000000000..f3e563f1c8f --- /dev/null +++ b/compiler/testData/codegen/box/enum/constructorWithReordering.kt @@ -0,0 +1,10 @@ +// IGNORE_BACKEND_FIR: JVM_IR +// IGNORE_BACKEND: JS +fun f(): String = "O" +fun g(): String = "K" + +enum class E(val x: String, val y: String) { + A(y = g(), x = f()) +} + +fun box(): String = E.A.x + E.A.y diff --git a/compiler/testData/ir/irText/classes/enum.kt b/compiler/testData/ir/irText/classes/enum.kt index 72cd8431719..c39bad34580 100644 --- a/compiler/testData/ir/irText/classes/enum.kt +++ b/compiler/testData/ir/irText/classes/enum.kt @@ -41,4 +41,10 @@ enum class TestEnum4(val x: Int) { enum class TestEnum5(val x: Int = 0) { TEST1, TEST2(), TEST3(0) -} \ No newline at end of file +} + +fun f(): Int = 1 + +enum class TestEnum6(val x: Int, val y: Int) { + TEST(y = f(), x = f()) +} diff --git a/compiler/testData/ir/irText/classes/enum.txt b/compiler/testData/ir/irText/classes/enum.txt index b868457e3c2..8787df0b8a1 100644 --- a/compiler/testData/ir/irText/classes/enum.txt +++ b/compiler/testData/ir/irText/classes/enum.txt @@ -145,7 +145,8 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum3.TEST CONSTRUCTOR visibility:private <> () returnType:.TestEnum3.TEST [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestEnum3' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestEnum3' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:TEST modality:FINAL visibility:public superTypes:[.TestEnum3]' FUN name:foo visibility:public modality:OPEN <> ($this:.TestEnum3.TEST) returnType:kotlin.Unit overridden: @@ -270,8 +271,9 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum4.TEST1 CONSTRUCTOR visibility:private <> () returnType:.TestEnum4.TEST1 [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor (x: kotlin.Int) [primary] declared in .TestEnum4' - x: CONST Int type=kotlin.Int value=1 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor (x: kotlin.Int) [primary] declared in .TestEnum4' + x: CONST Int type=kotlin.Int value=1 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:TEST1 modality:FINAL visibility:public superTypes:[.TestEnum4]' FUN name:foo visibility:public modality:OPEN <> ($this:.TestEnum4.TEST1) returnType:kotlin.Unit overridden: @@ -334,8 +336,9 @@ FILE fqName: fileName:/enum.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum4.TEST2 CONSTRUCTOR visibility:private <> () returnType:.TestEnum4.TEST2 [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor (x: kotlin.Int) [primary] declared in .TestEnum4' - x: CONST Int type=kotlin.Int value=2 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor (x: kotlin.Int) [primary] declared in .TestEnum4' + x: CONST Int type=kotlin.Int value=2 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:TEST2 modality:FINAL visibility:public superTypes:[.TestEnum4]' PROPERTY name:z visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:z type:kotlin.Int visibility:private [final] @@ -531,3 +534,94 @@ FILE fqName: fileName:/enum.kt FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:.TestEnum5 VALUE_PARAMETER name:value index:0 type:kotlin.String SYNTHETIC_BODY kind=ENUM_VALUEOF + FUN name:f visibility:public modality:FINAL <> () returnType:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun f (): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + CLASS ENUM_CLASS name:TestEnum6 modality:FINAL visibility:public superTypes:[kotlin.Enum<.TestEnum6>] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum6 + CONSTRUCTOR visibility:private <> (x:kotlin.Int, y:kotlin.Int) returnType:.TestEnum6 [primary] + VALUE_PARAMETER name:x index:0 type:kotlin.Int + VALUE_PARAMETER name:y index:1 type:kotlin.Int + BLOCK_BODY + ENUM_CONSTRUCTOR_CALL 'public constructor (name: kotlin.String, ordinal: kotlin.Int) [primary] declared in kotlin.Enum' + : .TestEnum6 + 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] + EXPRESSION_BODY + GET_VAR 'x: kotlin.Int declared in .TestEnum6.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestEnum6) returnType:kotlin.Int + correspondingProperty: PROPERTY name:x visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.TestEnum6 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestEnum6' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:x type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .TestEnum6 declared in .TestEnum6.' type=.TestEnum6 origin=null + PROPERTY name:y visibility:public modality:FINAL [val] + FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final] + EXPRESSION_BODY + GET_VAR 'y: kotlin.Int declared in .TestEnum6.' type=kotlin.Int origin=INITIALIZE_PROPERTY_FROM_PARAMETER + FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> ($this:.TestEnum6) returnType:kotlin.Int + correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [val] + $this: VALUE_PARAMETER name: type:.TestEnum6 + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun (): kotlin.Int declared in .TestEnum6' + GET_FIELD 'FIELD PROPERTY_BACKING_FIELD name:y type:kotlin.Int visibility:private [final]' type=kotlin.Int origin=null + receiver: GET_VAR ': .TestEnum6 declared in .TestEnum6.' type=.TestEnum6 origin=null + ENUM_ENTRY name:TEST + init: BLOCK type=.TestEnum6 origin=ARGUMENTS_REORDERING_FOR_CALL + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + CALL 'public final fun f (): kotlin.Int declared in ' type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CALL 'public final fun f (): kotlin.Int declared in ' type=kotlin.Int origin=null + ENUM_CONSTRUCTOR_CALL 'private constructor (x: kotlin.Int, y: kotlin.Int) [primary] declared in .TestEnum6' + x: GET_VAR 'val tmp_1: kotlin.Int [val] declared in .TestEnum6' type=kotlin.Int origin=null + y: GET_VAR 'val tmp_0: kotlin.Int [val] declared in .TestEnum6' type=kotlin.Int origin=null + FUN FAKE_OVERRIDE name:clone visibility:protected modality:FINAL <> ($this:kotlin.Enum<.TestEnum6>) returnType:kotlin.Any [fake_override] + overridden: + protected final fun clone (): kotlin.Any declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.TestEnum6> + FUN FAKE_OVERRIDE name:finalize visibility:protected/*protected and package*/ modality:FINAL <> ($this:kotlin.Enum<.TestEnum6>) returnType:kotlin.Unit [fake_override] + overridden: + protected/*protected and package*/ final fun finalize (): kotlin.Unit declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.TestEnum6> + FUN FAKE_OVERRIDE name:getDeclaringClass visibility:public modality:FINAL <> ($this:kotlin.Enum<.TestEnum6>) returnType:java.lang.Class<.TestEnum6?>? [fake_override] + overridden: + public final fun getDeclaringClass (): java.lang.Class? declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.TestEnum6> + FUN FAKE_OVERRIDE name:compareTo visibility:public modality:FINAL <> ($this:kotlin.Enum<.TestEnum6>, other:.TestEnum6) returnType:kotlin.Int [fake_override] + overridden: + public final fun compareTo (other: E of kotlin.Enum): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.TestEnum6> + VALUE_PARAMETER name:other index:0 type:.TestEnum6 + FUN FAKE_OVERRIDE name:equals visibility:public modality:FINAL <> ($this:kotlin.Enum<.TestEnum6>, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override] + overridden: + public final fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.TestEnum6> + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:FINAL <> ($this:kotlin.Enum<.TestEnum6>) returnType:kotlin.Int [fake_override] + overridden: + public final fun hashCode (): kotlin.Int declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.TestEnum6> + PROPERTY FAKE_OVERRIDE name:name visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum<.TestEnum6>) 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:kotlin.Enum<.TestEnum6> + PROPERTY FAKE_OVERRIDE name:ordinal visibility:public modality:FINAL [fake_override,val] + FUN FAKE_OVERRIDE name: visibility:public modality:FINAL <> ($this:kotlin.Enum<.TestEnum6>) 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:kotlin.Enum<.TestEnum6> + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Enum<.TestEnum6>) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Enum + $this: VALUE_PARAMETER name: type:kotlin.Enum<.TestEnum6> + FUN ENUM_CLASS_SPECIAL_MEMBER name:values visibility:public modality:FINAL <> () returnType:kotlin.Array<.TestEnum6> + SYNTHETIC_BODY kind=ENUM_VALUES + FUN ENUM_CLASS_SPECIAL_MEMBER name:valueOf visibility:public modality:FINAL <> (value:kotlin.String) returnType:.TestEnum6 + VALUE_PARAMETER name:value index:0 type:kotlin.String + SYNTHETIC_BODY kind=ENUM_VALUEOF diff --git a/compiler/testData/ir/irText/classes/enumClassModality.txt b/compiler/testData/ir/irText/classes/enumClassModality.txt index 2e3aca7895d..7910d5e9ab4 100644 --- a/compiler/testData/ir/irText/classes/enumClassModality.txt +++ b/compiler/testData/ir/irText/classes/enumClassModality.txt @@ -196,7 +196,8 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestOpenEnum1.X1 CONSTRUCTOR visibility:private <> () returnType:.TestOpenEnum1.X1 [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestOpenEnum1' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestOpenEnum1' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[.TestOpenEnum1]' FUN name:toString visibility:public modality:OPEN <> ($this:.TestOpenEnum1.X1) returnType:kotlin.String overridden: @@ -303,7 +304,8 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestOpenEnum2.X1 CONSTRUCTOR visibility:private <> () returnType:.TestOpenEnum2.X1 [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestOpenEnum2' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestOpenEnum2' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[.TestOpenEnum2]' FUN name:foo visibility:public modality:OPEN <> ($this:.TestOpenEnum2.X1) returnType:kotlin.Unit overridden: @@ -415,7 +417,8 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAbstractEnum1.X1 CONSTRUCTOR visibility:private <> () returnType:.TestAbstractEnum1.X1 [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestAbstractEnum1' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestAbstractEnum1' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[.TestAbstractEnum1]' FUN name:foo visibility:public modality:OPEN <> ($this:.TestAbstractEnum1.X1) returnType:kotlin.Unit overridden: @@ -543,7 +546,8 @@ FILE fqName: fileName:/enumClassModality.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestAbstractEnum2.X1 CONSTRUCTOR visibility:private <> () returnType:.TestAbstractEnum2.X1 [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestAbstractEnum2' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestAbstractEnum2' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:X1 modality:FINAL visibility:public superTypes:[.TestAbstractEnum2]' FUN name:foo visibility:public modality:OPEN <> ($this:.TestAbstractEnum2.X1) returnType:kotlin.Unit overridden: diff --git a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.txt b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.txt index 04902cdb598..d59344ee031 100644 --- a/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.txt +++ b/compiler/testData/ir/irText/classes/enumWithSecondaryCtor.txt @@ -171,7 +171,8 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2.ZERO CONSTRUCTOR visibility:private <> () returnType:.Test2.ZERO [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () declared in .Test2' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () declared in .Test2' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:ZERO modality:FINAL visibility:public superTypes:[.Test2]' FUN name:foo visibility:public modality:OPEN <> ($this:.Test2.ZERO) returnType:kotlin.Unit overridden: @@ -234,8 +235,9 @@ FILE fqName: fileName:/enumWithSecondaryCtor.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Test2.ONE CONSTRUCTOR visibility:private <> () returnType:.Test2.ONE [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor (x: kotlin.Int) [primary] declared in .Test2' - x: CONST Int type=kotlin.Int value=1 + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor (x: kotlin.Int) [primary] declared in .Test2' + x: CONST Int type=kotlin.Int value=1 INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:ONE modality:FINAL visibility:public superTypes:[.Test2]' FUN name:foo visibility:public modality:OPEN <> ($this:.Test2.ONE) returnType:kotlin.Unit overridden: diff --git a/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.txt b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.txt index ff39624e852..103cc4ee210 100644 --- a/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.txt +++ b/compiler/testData/ir/irText/declarations/annotations/enumEntriesWithAnnotations.txt @@ -48,7 +48,8 @@ FILE fqName: fileName:/enumEntriesWithAnnotations.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.TestEnum.ENTRY2 CONSTRUCTOR visibility:private <> () returnType:.TestEnum.ENTRY2 [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestEnum' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .TestEnum' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:ENTRY2 modality:FINAL visibility:public superTypes:[.TestEnum]' 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/expressions/enumEntryAsReceiver.txt b/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.txt index e63f419ed1b..a3da659f078 100644 --- a/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.txt +++ b/compiler/testData/ir/irText/expressions/enumEntryAsReceiver.txt @@ -12,7 +12,8 @@ FILE fqName: fileName:/enumEntryAsReceiver.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.X.B CONSTRUCTOR visibility:private <> () returnType:.X.B [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .X' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .X' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:B modality:FINAL visibility:public superTypes:[.X]' PROPERTY name:value2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:value2 type:kotlin.String visibility:private [final] diff --git a/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.txt b/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.txt index 670cc637dc0..e6437d452f4 100644 --- a/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.txt +++ b/compiler/testData/ir/irText/expressions/enumEntryReferenceFromEnumEntryClass.txt @@ -12,7 +12,8 @@ FILE fqName: fileName:/enumEntryReferenceFromEnumEntryClass.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.MyEnum.Z CONSTRUCTOR visibility:private <> () returnType:.MyEnum.Z [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .MyEnum' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:Z modality:FINAL visibility:public superTypes:[.MyEnum]' PROPERTY name:counter visibility:public modality:FINAL [var] FIELD PROPERTY_BACKING_FIELD name:counter type:kotlin.Int visibility:private diff --git a/compiler/testData/ir/irText/singletons/enumEntry.txt b/compiler/testData/ir/irText/singletons/enumEntry.txt index 76b533e03d0..bc61c47a1d7 100644 --- a/compiler/testData/ir/irText/singletons/enumEntry.txt +++ b/compiler/testData/ir/irText/singletons/enumEntry.txt @@ -12,7 +12,8 @@ FILE fqName: fileName:/enumEntry.kt $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.Z.ENTRY CONSTRUCTOR visibility:private <> () returnType:.Z.ENTRY [primary] BLOCK_BODY - ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Z' + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + ENUM_CONSTRUCTOR_CALL 'private constructor () [primary] declared in .Z' INSTANCE_INITIALIZER_CALL classDescriptor='CLASS ENUM_ENTRY name:ENTRY modality:FINAL visibility:public superTypes:[.Z]' FUN name:test visibility:public modality:FINAL <> ($this:.Z.ENTRY) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Z.ENTRY diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 2b71472fe73..50e39d499fb 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -10487,6 +10487,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/enum/companionObjectInEnum.kt"); } + @TestMetadata("constructorWithReordering.kt") + public void testConstructorWithReordering() throws Exception { + runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt"); + } + @TestMetadata("deepInnerClassInEnumEntryClass.kt") public void testDeepInnerClassInEnumEntryClass() throws Exception { runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 4f83826e2e8..c55f75b70fc 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -10487,6 +10487,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/enum/companionObjectInEnum.kt"); } + @TestMetadata("constructorWithReordering.kt") + public void testConstructorWithReordering() throws Exception { + runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt"); + } + @TestMetadata("deepInnerClassInEnumEntryClass.kt") public void testDeepInnerClassInEnumEntryClass() throws Exception { runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 7de4d0f4831..4f8a327f81c 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -9337,6 +9337,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/enum/companionObjectInEnum.kt"); } + @TestMetadata("constructorWithReordering.kt") + public void testConstructorWithReordering() throws Exception { + runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt"); + } + @TestMetadata("deepInnerClassInEnumEntryClass.kt") public void testDeepInnerClassInEnumEntryClass() throws Exception { runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 31ae43743ce..5fc054492a8 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -9337,6 +9337,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/enum/companionObjectInEnum.kt"); } + @TestMetadata("constructorWithReordering.kt") + public void testConstructorWithReordering() throws Exception { + runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt"); + } + @TestMetadata("deepInnerClassInEnumEntryClass.kt") public void testDeepInnerClassInEnumEntryClass() throws Exception { runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index c1ce8b99ffc..52efe99975b 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -8112,6 +8112,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/enum/companionObjectInEnum.kt"); } + @TestMetadata("constructorWithReordering.kt") + public void testConstructorWithReordering() throws Exception { + runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt"); + } + @TestMetadata("deepInnerClassInEnumEntryClass.kt") public void testDeepInnerClassInEnumEntryClass() throws Exception { runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 398767781ac..d963764e19f 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -9187,6 +9187,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/enum/companionObjectInEnum.kt"); } + @TestMetadata("constructorWithReordering.kt") + public void testConstructorWithReordering() throws Exception { + runTest("compiler/testData/codegen/box/enum/constructorWithReordering.kt"); + } + @TestMetadata("deepInnerClassInEnumEntryClass.kt") public void testDeepInnerClassInEnumEntryClass() throws Exception { runTest("compiler/testData/codegen/box/enum/deepInnerClassInEnumEntryClass.kt");