diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt index 05c0ba68718..6bfb2a39e40 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt @@ -165,7 +165,6 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: val irBlockBody = IrBlockBodyImpl(ktClassOrObject.startOffset, ktClassOrObject.endOffset) generateSuperConstructorCall(irBlockBody, ktClassOrObject) - generateInitializersForPropertiesDefinedInPrimaryConstructor(irBlockBody, ktClassOrObject) val classDescriptor = (scopeOwner as ConstructorDescriptor).containingDeclaration irBlockBody.addStatement(IrInstanceInitializerCallImpl(ktClassOrObject.startOffset, ktClassOrObject.endOffset, classDescriptor)) @@ -280,33 +279,5 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: enumClassConstructor, enumEntryOrNull) } - private fun generateInitializersForPropertiesDefinedInPrimaryConstructor(irBlockBody: IrBlockBodyImpl, ktClassOrObject: KtClassOrObject) { - ktClassOrObject.getPrimaryConstructor()?.let { ktPrimaryConstructor -> - for (ktParameter in ktPrimaryConstructor.valueParameters) { - if (ktParameter.hasValOrVar()) { - val propertyDescriptor = getOrFail(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, ktParameter) - val valueParameterDescriptor = getOrFail(BindingContext.VALUE_PARAMETER, ktParameter) - - irBlockBody.addStatement( - initializePropertyInPrimaryConstructor( - ktParameter, propertyDescriptor, - IrGetVariableImpl(ktParameter.startOffset, ktParameter.endOffset, - valueParameterDescriptor, IrOperator.INITIALIZE_PROPERTY_FROM_PARAMETER) - )) - } - } - } - } - - private fun initializePropertyInPrimaryConstructor( - ktElement: KtElement, - propertyDescriptor: PropertyDescriptor, - value: IrExpression - ): IrExpression { - val thisClass = propertyDescriptor.containingDeclaration as ClassDescriptor - return IrSetBackingFieldImpl(ktElement.startOffset, ktElement.endOffset, propertyDescriptor, - IrThisReferenceImpl(ktElement.startOffset, ktElement.endOffset, thisClass.defaultType, thisClass), - value) - } } diff --git a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt index 4eacab9a08d..0bd950aeb90 100644 --- a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt +++ b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt @@ -3,12 +3,6 @@ FILE /argumentReorderingInDelegatingConstructorCall.kt CONSTRUCTOR public constructor Base(x: kotlin.Int, y: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Base' type=Base - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD 'y: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Base' type=Base - value: GET_VAR 'value-parameter y: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Base' PROPERTY public final val x: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/classMembers.txt b/compiler/testData/ir/irText/classes/classMembers.txt index 332819f90d8..e59e9e070af 100644 --- a/compiler/testData/ir/irText/classes/classMembers.txt +++ b/compiler/testData/ir/irText/classes/classMembers.txt @@ -5,12 +5,6 @@ FILE /classMembers.kt CONST Int type=kotlin.Int value='1' BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'y: Int' type=kotlin.Unit operator=null - receiver: THIS of 'C' type=C - value: GET_VAR 'value-parameter y: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD 'z: Int' type=kotlin.Unit operator=null - receiver: THIS of 'C' type=C - value: GET_VAR 'value-parameter z: Int = ...' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='C' PROPERTY public final val y: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/dataClasses.txt b/compiler/testData/ir/irText/classes/dataClasses.txt index 4b9ecdb84da..5e1d139bb9a 100644 --- a/compiler/testData/ir/irText/classes/dataClasses.txt +++ b/compiler/testData/ir/irText/classes/dataClasses.txt @@ -3,15 +3,6 @@ FILE /dataClasses.kt CONSTRUCTOR public constructor Test1(x: kotlin.Int, y: kotlin.String, z: kotlin.Any) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Test1' type=Test1 - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD 'y: String' type=kotlin.Unit operator=null - receiver: THIS of 'Test1' type=Test1 - value: GET_VAR 'value-parameter y: String' type=kotlin.String operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD 'z: Any' type=kotlin.Unit operator=null - receiver: THIS of 'Test1' type=Test1 - value: GET_VAR 'value-parameter z: Any' type=kotlin.Any operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Test1' PROPERTY public final val x: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/enum.txt b/compiler/testData/ir/irText/classes/enum.txt index d9dc95b27eb..037ed52fb0f 100644 --- a/compiler/testData/ir/irText/classes/enum.txt +++ b/compiler/testData/ir/irText/classes/enum.txt @@ -16,9 +16,6 @@ FILE /enum.kt CONSTRUCTOR private constructor TestEnum2(x: kotlin.Int) BLOCK_BODY ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' super - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'TestEnum2' type=TestEnum2 - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='TestEnum2' PROPERTY public final val x: kotlin.Int EXPRESSION_BODY @@ -61,9 +58,6 @@ FILE /enum.kt CONSTRUCTOR private constructor TestEnum4(x: kotlin.Int) BLOCK_BODY ENUM_CONSTRUCTOR_CALL 'constructor Enum(String, Int)' super - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'TestEnum4' type=TestEnum4 - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='TestEnum4' PROPERTY public final val x: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/initBlock.txt b/compiler/testData/ir/irText/classes/initBlock.txt index 272e945d529..d2c3a26542b 100644 --- a/compiler/testData/ir/irText/classes/initBlock.txt +++ b/compiler/testData/ir/irText/classes/initBlock.txt @@ -11,9 +11,6 @@ FILE /initBlock.kt CONSTRUCTOR public constructor Test2(x: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Test2' type=Test2 - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Test2' PROPERTY public final val x: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/initVal.txt b/compiler/testData/ir/irText/classes/initVal.txt index d467ad626c8..11f8cdbc7dc 100644 --- a/compiler/testData/ir/irText/classes/initVal.txt +++ b/compiler/testData/ir/irText/classes/initVal.txt @@ -3,9 +3,6 @@ FILE /initVal.kt CONSTRUCTOR public constructor TestInitValFromParameter(x: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'TestInitValFromParameter' type=TestInitValFromParameter - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='TestInitValFromParameter' PROPERTY public final val x: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/initVar.txt b/compiler/testData/ir/irText/classes/initVar.txt index 28ed719ef56..7fec0f6294e 100644 --- a/compiler/testData/ir/irText/classes/initVar.txt +++ b/compiler/testData/ir/irText/classes/initVar.txt @@ -3,9 +3,6 @@ FILE /initVar.kt CONSTRUCTOR public constructor TestInitVarFromParameter(x: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'TestInitVarFromParameter' type=TestInitVarFromParameter - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='TestInitVarFromParameter' PROPERTY public final var x: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/primaryConstructor.txt b/compiler/testData/ir/irText/classes/primaryConstructor.txt index c79d1cc7145..760acbdae23 100644 --- a/compiler/testData/ir/irText/classes/primaryConstructor.txt +++ b/compiler/testData/ir/irText/classes/primaryConstructor.txt @@ -3,12 +3,6 @@ FILE /primaryConstructor.kt CONSTRUCTOR public constructor Test1(x: kotlin.Int, y: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Test1' type=Test1 - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD 'y: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Test1' type=Test1 - value: GET_VAR 'value-parameter y: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Test1' PROPERTY public final val x: kotlin.Int EXPRESSION_BODY @@ -20,9 +14,6 @@ FILE /primaryConstructor.kt CONSTRUCTOR public constructor Test2(x: kotlin.Int, y: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'y: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Test2' type=Test2 - value: GET_VAR 'value-parameter y: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Test2' PROPERTY public final val y: kotlin.Int EXPRESSION_BODY @@ -34,9 +25,6 @@ FILE /primaryConstructor.kt CONSTRUCTOR public constructor Test3(x: kotlin.Int, y: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'y: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Test3' type=Test3 - value: GET_VAR 'value-parameter y: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Test3' PROPERTY public final val y: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt index af9ec183b6b..85b22beb76c 100644 --- a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt +++ b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt @@ -18,12 +18,6 @@ FILE /primaryConstructorWithSuperConstructorCall.kt CONSTRUCTOR public constructor TestWithDelegatingConstructor(x: kotlin.Int, y: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Base()' - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'TestWithDelegatingConstructor' type=TestWithDelegatingConstructor - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD 'y: Int' type=kotlin.Unit operator=null - receiver: THIS of 'TestWithDelegatingConstructor' type=TestWithDelegatingConstructor - value: GET_VAR 'value-parameter y: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='TestWithDelegatingConstructor' PROPERTY public final val x: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/classes/sealedClasses.txt b/compiler/testData/ir/irText/classes/sealedClasses.txt index 4726ccde2e8..b46f90a4428 100644 --- a/compiler/testData/ir/irText/classes/sealedClasses.txt +++ b/compiler/testData/ir/irText/classes/sealedClasses.txt @@ -8,9 +8,6 @@ FILE /sealedClasses.kt CONSTRUCTOR public constructor Const(number: kotlin.Double) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Expr()' - SET_BACKING_FIELD 'number: Double' type=kotlin.Unit operator=null - receiver: THIS of 'Const' type=Expr.Const - value: GET_VAR 'value-parameter number: Double' type=kotlin.Double operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Const' PROPERTY public final val number: kotlin.Double EXPRESSION_BODY @@ -19,12 +16,6 @@ FILE /sealedClasses.kt CONSTRUCTOR public constructor Sum(e1: Expr, e2: Expr) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Expr()' - SET_BACKING_FIELD 'e1: Expr' type=kotlin.Unit operator=null - receiver: THIS of 'Sum' type=Expr.Sum - value: GET_VAR 'value-parameter e1: Expr' type=Expr operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD 'e2: Expr' type=kotlin.Unit operator=null - receiver: THIS of 'Sum' type=Expr.Sum - value: GET_VAR 'value-parameter e2: Expr' type=Expr operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Sum' PROPERTY public final val e1: Expr EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/declarations/delegatedProperties.txt b/compiler/testData/ir/irText/declarations/delegatedProperties.txt index e79e0c5138f..4b750faf555 100644 --- a/compiler/testData/ir/irText/declarations/delegatedProperties.txt +++ b/compiler/testData/ir/irText/declarations/delegatedProperties.txt @@ -20,9 +20,6 @@ FILE /delegatedProperties.kt CONSTRUCTOR public constructor C(map: kotlin.collections.MutableMap) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'map: MutableMap' type=kotlin.Unit operator=null - receiver: THIS of 'C' type=C - value: GET_VAR 'value-parameter map: MutableMap' type=kotlin.collections.MutableMap operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='C' PROPERTY public final val map: kotlin.collections.MutableMap EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt index 21885d9a1ba..97f02995469 100644 --- a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt +++ b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt @@ -15,9 +15,6 @@ FILE /arrayAugmentedAssignment1.kt CONSTRUCTOR public constructor C(x: kotlin.IntArray) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'x: IntArray' type=kotlin.Unit operator=null - receiver: THIS of 'C' type=C - value: GET_VAR 'value-parameter x: IntArray' type=kotlin.IntArray operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='C' PROPERTY public final val x: kotlin.IntArray EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/assignments.txt b/compiler/testData/ir/irText/expressions/assignments.txt index dfad8b8ee52..f9a52f0c0c4 100644 --- a/compiler/testData/ir/irText/expressions/assignments.txt +++ b/compiler/testData/ir/irText/expressions/assignments.txt @@ -3,9 +3,6 @@ FILE /assignments.kt CONSTRUCTOR public constructor Ref(x: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'x: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Ref' type=Ref - value: GET_VAR 'value-parameter x: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Ref' PROPERTY public final var x: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.txt b/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.txt index d60d0e5a54d..57d91680e45 100644 --- a/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.txt +++ b/compiler/testData/ir/irText/expressions/complexAugmentedAssignment.txt @@ -92,9 +92,6 @@ FILE /complexAugmentedAssignment.kt CONST Int type=kotlin.Int value='0' BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 's: Int' type=kotlin.Unit operator=null - receiver: THIS of 'B' type=B - value: GET_VAR 'value-parameter s: Int = ...' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='B' PROPERTY public final var s: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt index 1e8f1645162..be55f1341e1 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt @@ -8,9 +8,6 @@ FILE /forWithImplicitReceivers.kt CONSTRUCTOR public constructor IntCell(value: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'value: Int' type=kotlin.Unit operator=null - receiver: THIS of 'IntCell' type=IntCell - value: GET_VAR 'value-parameter value: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='IntCell' PROPERTY public final var value: kotlin.Int EXPRESSION_BODY diff --git a/compiler/testData/ir/irText/expressions/safeCalls.txt b/compiler/testData/ir/irText/expressions/safeCalls.txt index 91f4cf7e0bd..0ed307617cb 100644 --- a/compiler/testData/ir/irText/expressions/safeCalls.txt +++ b/compiler/testData/ir/irText/expressions/safeCalls.txt @@ -3,9 +3,6 @@ FILE /safeCalls.kt CONSTRUCTOR public constructor Ref(value: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL 'constructor Any()' - SET_BACKING_FIELD 'value: Int' type=kotlin.Unit operator=null - receiver: THIS of 'Ref' type=Ref - value: GET_VAR 'value-parameter value: Int' type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER INSTANCE_INITIALIZER_CALL classDescriptor='Ref' PROPERTY public final var value: kotlin.Int EXPRESSION_BODY