From 1b5dd5035979f5df4153eeb6ef78a0d7661043aa Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 1 Sep 2016 18:32:07 +0300 Subject: [PATCH] Represent class instance initialization "as from resolve". --- .../kotlin/psi2ir/generators/BodyGenerator.kt | 55 +++++---------- .../psi2ir/generators/ClassGenerator.kt | 20 ++---- .../psi2ir/generators/DeclarationGenerator.kt | 23 +++++-- .../src/org/jetbrains/kotlin/ir/IrSlots.kt | 1 + .../ir/declarations/IrAnonymousInitializer.kt | 68 +++++++++++++++++++ .../kotlin/ir/declarations/IrClass.kt | 47 ++++++------- .../kotlin/ir/declarations/IrDeclaration.kt | 1 + ...rsCall.kt => IrInstanceInitializerCall.kt} | 8 +-- .../jetbrains/kotlin/ir/util/DumpIrTree.kt | 9 --- .../kotlin/ir/util/RenderIrElement.kt | 7 +- .../kotlin/ir/visitors/IrElementVisitor.kt | 3 +- ...tReorderingInDelegatingConstructorCall.txt | 5 +- .../ir/irText/classes/classMembers.txt | 5 +- .../testData/ir/irText/classes/classes.txt | 4 ++ .../ir/irText/classes/companionObject.txt | 4 ++ .../ir/irText/classes/dataClasses.txt | 1 + ...onstructorCallsInSecondaryConstructors.txt | 6 +- compiler/testData/ir/irText/classes/enum.txt | 16 +++-- .../testData/ir/irText/classes/initBlock.kt | 31 +++++++++ .../testData/ir/irText/classes/initBlock.txt | 41 +++++++++++ .../testData/ir/irText/classes/initVal.txt | 12 ++-- .../testData/ir/irText/classes/initVar.txt | 32 ++++----- .../ir/irText/classes/localClasses.txt | 1 + .../classes/objectLiteralExpressions.txt | 6 ++ .../ir/irText/classes/primaryConstructor.txt | 12 ++-- ...aryConstructorWithSuperConstructorCall.txt | 4 ++ .../ir/irText/classes/qualifiedSuperCalls.txt | 1 + ...nstructorWithInitializersFromClassBody.txt | 14 ++-- .../irText/classes/secondaryConstructors.txt | 3 +- .../testData/ir/irText/classes/superCalls.txt | 4 +- .../declarations/delegatedProperties.txt | 1 + .../expressions/arrayAugmentedAssignment1.txt | 1 + .../ir/irText/expressions/assignments.txt | 1 + .../expressions/augmentedAssignment2.txt | 1 + .../irText/expressions/chainOfSafeCalls.txt | 1 + .../expressions/forWithImplicitReceivers.txt | 2 + .../expressions/jvmStaticFieldReference.txt | 20 ++---- .../safeCallWithIncrementDecrement.txt | 1 + .../ir/irText/expressions/safeCalls.txt | 1 + .../testData/ir/irText/expressions/values.txt | 4 ++ .../testData/ir/irText/expressions/when.txt | 1 + .../lambdas/multipleImplicitReceivers.txt | 2 + .../kotlin/ir/IrTextTestCaseGenerated.java | 6 ++ 43 files changed, 322 insertions(+), 164 deletions(-) create mode 100644 compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrAnonymousInitializer.kt rename compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/{IrNestedInitializersCall.kt => IrInstanceInitializerCall.kt} (84%) create mode 100644 compiler/testData/ir/irText/classes/initBlock.kt create mode 100644 compiler/testData/ir/irText/classes/initBlock.txt 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 4cd4c9b8205..9b012e7edcc 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 @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.IrFunctionBase import org.jetbrains.kotlin.ir.descriptors.IrPropertyDelegateDescriptor import org.jetbrains.kotlin.ir.expressions.* @@ -32,7 +31,6 @@ import org.jetbrains.kotlin.psi2ir.builders.irReturn import org.jetbrains.kotlin.psi2ir.intermediate.VariableLValue import org.jetbrains.kotlin.psi2ir.intermediate.setExplicitReceiverValue import org.jetbrains.kotlin.resolve.BindingContext -import java.lang.AssertionError import java.util.* class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: GeneratorContext): GeneratorWithScope { @@ -146,7 +144,9 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: generateSuperConstructorCall(irBlockBody, ktClassOrObject) generateInitializersForPropertiesDefinedInPrimaryConstructor(irBlockBody, ktClassOrObject) - generateInitializersForClassBody(irBlockBody, ktClassOrObject) + + val classDescriptor = (scopeOwner as ConstructorDescriptor).containingDeclaration + irBlockBody.addStatement(IrInstanceInitializerCallImpl(ktClassOrObject.startOffset, ktClassOrObject.endOffset, classDescriptor)) return irBlockBody } @@ -157,7 +157,7 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: generateDelegatingConstructorCall(irBlockBody, ktConstructor) val classDescriptor = getOrFail(BindingContext.CONSTRUCTOR, ktConstructor).containingDeclaration - irBlockBody.addStatement(IrNestedInitializersCallImpl(ktConstructor.startOffset, ktConstructor.endOffset, classDescriptor)) + irBlockBody.addStatement(IrInstanceInitializerCallImpl(ktConstructor.startOffset, ktConstructor.endOffset, classDescriptor)) ktConstructor.bodyExpression?.let { ktBody -> createStatementGenerator().generateBlockBodyStatements(irBlockBody, ktBody) @@ -197,6 +197,18 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: return generateEnumConstructorCallOrSuperCall(ktEnumEntry, enumEntryDescriptor.containingDeclaration as ClassDescriptor, null) } + fun generateAnonymousInitializerBody(ktAnonymousInitializer: KtAnonymousInitializer): IrBlockBody { + val ktBody = ktAnonymousInitializer.body!! + val irBlockBody = IrBlockBodyImpl(ktBody.startOffset, ktBody.endOffset) + if (ktBody is KtBlockExpression) { + createStatementGenerator().generateBlockBodyStatements(irBlockBody, ktBody) + } + else { + irBlockBody.addStatement(createStatementGenerator().generateStatement(ktBody)) + } + return irBlockBody + } + fun generateEnumEntryInitializer(ktEnumEntry: KtEnumEntry, enumEntryDescriptor: ClassDescriptor): IrExpression { if (ktEnumEntry.declarations.isNotEmpty()) { val enumEntryConstructor = enumEntryDescriptor.unsubstitutedPrimaryConstructor!! @@ -229,41 +241,6 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: enumClassConstructor, enumEntryOrNull) } - fun generateNestedInitializersBody(ktClassOrObject: KtClassOrObject): IrBody { - val irBody = IrBlockBodyImpl(ktClassOrObject.startOffset, ktClassOrObject.endOffset) - generateInitializersForClassBody(irBody, ktClassOrObject) - return irBody - } - - private fun generateInitializersForClassBody(irBlockBody: IrBlockBodyImpl, ktClassOrObject: KtClassOrObject) { - ktClassOrObject.getBody()?.let { ktClassBody -> - for (ktDeclaration in ktClassBody.declarations) { - when (ktDeclaration) { - is KtProperty -> generateInitializerForPropertyDefinedInClassBody(irBlockBody, ktDeclaration) - is KtClassInitializer -> generateAnonymousInitializer(irBlockBody, ktDeclaration) - } - } - } - } - - private fun generateAnonymousInitializer(irBlockBody: IrBlockBodyImpl, ktClassInitializer: KtClassInitializer) { - if (ktClassInitializer.body == null) return - val irInitializer = generateAnonymousInitializer(ktClassInitializer) - irBlockBody.addStatement(irInitializer) - } - - fun generateAnonymousInitializer(ktInitializer: KtAnonymousInitializer): IrStatement { - return createStatementGenerator().generateStatement(ktInitializer.body!!) - } - - private fun generateInitializerForPropertyDefinedInClassBody(irBlockBody: IrBlockBodyImpl, ktProperty: KtProperty) { - val propertyDescriptor = getOrFail(BindingContext.VARIABLE, ktProperty) as PropertyDescriptor - ktProperty.initializer?.let { ktInitializer -> - irBlockBody.addStatement(createPropertyInitializationExpression( - ktProperty, propertyDescriptor, createStatementGenerator().generateExpression(ktInitializer))) - } - } - private fun generateInitializersForPropertiesDefinedInPrimaryConstructor(irBlockBody: IrBlockBodyImpl, ktClassOrObject: KtClassOrObject) { ktClassOrObject.getPrimaryConstructor()?.let { ktPrimaryConstructor -> for (ktParameter in ktPrimaryConstructor.valueParameters) { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt index 866f5b7ee5a..8ab6f180fa0 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt @@ -21,10 +21,11 @@ import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrExpressionBodyImpl import org.jetbrains.kotlin.ir.expressions.IrGetVariableImpl import org.jetbrains.kotlin.ir.expressions.IrOperator -import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.KtClassOrObject +import org.jetbrains.kotlin.psi.KtEnumEntry +import org.jetbrains.kotlin.psi.KtParameter import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -import org.jetbrains.kotlin.psi2ir.isConstructorDelegatingToSuper import org.jetbrains.kotlin.resolve.BindingContext class ClassGenerator(val declarationGenerator: DeclarationGenerator) : Generator { @@ -40,10 +41,6 @@ class ClassGenerator(val declarationGenerator: DeclarationGenerator) : Generator generateMembersDeclaredInClassBody(irClass, ktClassOrObject) - if (shouldGenerateNestedInitializers(ktClassOrObject)) { - irClass.nestedInitializers = BodyGenerator(descriptor, context).generateNestedInitializersBody(ktClassOrObject) - } - if (descriptor.isData) { generateAdditionalMembersForDataClass(irClass, ktClassOrObject) } @@ -63,12 +60,6 @@ class ClassGenerator(val declarationGenerator: DeclarationGenerator) : Generator EnumClassMembersGenerator(context).generateSpecialMembers(irClass) } - private fun shouldGenerateNestedInitializers(ktClassOrObject: KtClassOrObject): Boolean { - val ktClassBody = ktClassOrObject.getBody() ?: return false - - return ktClassBody.declarations.any { it is KtSecondaryConstructor && it.isConstructorDelegatingToSuper(context.bindingContext) } - } - private fun generatePrimaryConstructor(irClass: IrClassImpl, ktClassOrObject: KtClassOrObject) { val primaryConstructorDescriptor = irClass.descriptor.unsubstitutedPrimaryConstructor ?: return @@ -97,10 +88,7 @@ class ClassGenerator(val declarationGenerator: DeclarationGenerator) : Generator private fun generateMembersDeclaredInClassBody(irClass: IrClassImpl, ktClassOrObject: KtClassOrObject) { ktClassOrObject.getBody()?.let { ktClassBody -> for (ktDeclaration in ktClassBody.declarations) { - if (ktDeclaration is KtAnonymousInitializer) continue - - val irMember = declarationGenerator.generateMemberDeclaration(ktDeclaration) - + val irMember = declarationGenerator.generateClassMemberDeclaration(ktDeclaration, irClass.descriptor) irClass.addMember(irMember) } } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DeclarationGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DeclarationGenerator.kt index a549200002f..7733e1ec29a 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DeclarationGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DeclarationGenerator.kt @@ -32,12 +32,8 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator { when (ktDeclaration) { is KtNamedFunction -> generateFunctionDeclaration(ktDeclaration) - is KtSecondaryConstructor -> - generateSecondaryConstructor(ktDeclaration) is KtProperty -> generatePropertyDeclaration(ktDeclaration) - is KtEnumEntry -> - generateEnumEntryDeclaration(ktDeclaration) is KtClassOrObject -> generateClassOrObjectDeclaration(ktDeclaration) is KtTypeAlias -> @@ -49,6 +45,18 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator { ) } + fun generateClassMemberDeclaration(ktDeclaration: KtDeclaration, classDescriptor: ClassDescriptor): IrDeclaration = + when (ktDeclaration) { + is KtAnonymousInitializer -> + generateAnonymousInitializerDeclaration(ktDeclaration, classDescriptor) + is KtSecondaryConstructor -> + generateSecondaryConstructor(ktDeclaration) + is KtEnumEntry -> + generateEnumEntryDeclaration(ktDeclaration) + else -> + generateMemberDeclaration(ktDeclaration) + } + private fun generateEnumEntryDeclaration(ktEnumEntry: KtEnumEntry): IrEnumEntry = ClassGenerator(this).generateEnumEntry(ktEnumEntry) @@ -59,6 +67,13 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator { IrTypeAliasImpl(ktDeclaration.startOffset, ktDeclaration.endOffset, IrDeclarationOrigin.DEFINED, getOrFail(BindingContext.TYPE_ALIAS, ktDeclaration)) + fun generateAnonymousInitializerDeclaration(ktAnonymousInitializer: KtAnonymousInitializer, classDescriptor: ClassDescriptor): IrDeclaration { + val irAnonymousInitializer = IrAnonymousInitializerImpl(ktAnonymousInitializer.startOffset, ktAnonymousInitializer.endOffset, + IrDeclarationOrigin.DEFINED, classDescriptor) + irAnonymousInitializer.body = BodyGenerator(classDescriptor, context).generateAnonymousInitializerBody(ktAnonymousInitializer) + return irAnonymousInitializer + } + fun generateFunctionDeclaration(ktFunction: KtNamedFunction): IrGeneralFunction { val functionDescriptor = getOrFail(BindingContext.FUNCTION, ktFunction) val irFunction = IrFunctionImpl(ktFunction.startOffset, ktFunction.endOffset, IrDeclarationOrigin.DEFINED, functionDescriptor) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrSlots.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrSlots.kt index 5ac349ddf4d..736468c6c3e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrSlots.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrSlots.kt @@ -23,6 +23,7 @@ const val ARGUMENT1_SLOT = 1 const val DISPATCH_RECEIVER_SLOT = -1 const val EXTENSION_RECEIVER_SLOT = -2 const val FUNCTION_BODY_SLOT = -1 +const val ANONYMOUS_INITIALIZER_BODY_SLOT = -1 const val MODULE_SLOT = 0 const val INITIALIZER_SLOT = 0 const val IF_CONDITION_SLOT = 0 diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrAnonymousInitializer.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrAnonymousInitializer.kt new file mode 100644 index 00000000000..386bab20ca5 --- /dev/null +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrAnonymousInitializer.kt @@ -0,0 +1,68 @@ +/* + * Copyright 2010-2016 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.kotlin.ir.declarations + +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.ir.* +import org.jetbrains.kotlin.ir.expressions.IrBlockBody +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + +interface IrAnonymousInitializer : IrDeclaration { + override val descriptor: ClassDescriptor // TODO special descriptor for anonymous initializer blocks + + override val declarationKind: IrDeclarationKind + get() = IrDeclarationKind.ANONYMOUS_INITIALIZER + + var body: IrBlockBody +} + +class IrAnonymousInitializerImpl( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin, + override val descriptor: ClassDescriptor +) : IrDeclarationBase(startOffset, endOffset, origin), IrAnonymousInitializer { + private var bodyImpl: IrBlockBody? = null + override var body: IrBlockBody + get() = bodyImpl!! + set(value) { + value.assertDetached() + bodyImpl?.detach() + bodyImpl = value + value.setTreeLocation(this, ANONYMOUS_INITIALIZER_BODY_SLOT) + } + + override fun getChild(slot: Int): IrElement? = + when (slot) { + ANONYMOUS_INITIALIZER_BODY_SLOT -> body + else -> null + } + + override fun replaceChild(slot: Int, newChild: IrElement) { + when (slot) { + ANONYMOUS_INITIALIZER_BODY_SLOT -> body = newChild.assertCast() + } + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitAnonymousInitializer(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + body.accept(visitor, data) + } +} \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt index 1a4d1634a7e..fb8a5d899f7 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrClass.kt @@ -29,10 +29,23 @@ interface IrClass : IrDeclaration { override val descriptor: ClassDescriptor val members: List - - var nestedInitializers: IrBody? } +fun IrClass.getInstanceInitializerMembers() = + members.filter { + when (it) { + is IrDelegate -> + true + is IrAnonymousInitializer -> + true + is IrSimpleProperty -> + it.valueInitializer != null + is IrDelegatedProperty -> + true + else -> false + } + } + class IrClassImpl( startOffset: Int, endOffset: Int, @@ -47,41 +60,21 @@ class IrClassImpl( members.add(member) } - override var nestedInitializers: IrBody? = null - set(value) { - value?.assertDetached() - field?.detach() - field = value - value?.setTreeLocation(this, NESTED_INITIALIZERS_SLOT) - } - override fun getChild(slot: Int): IrElement? = - when (slot) { - NESTED_INITIALIZERS_SLOT -> nestedInitializers - else -> members.getOrNull(slot) - } + members.getOrNull(slot) override fun replaceChild(slot: Int, newChild: IrElement) { - when (slot) { - NESTED_INITIALIZERS_SLOT -> - nestedInitializers = newChild.assertCast() - else -> { - newChild.assertDetached() - members.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) - members[slot] = newChild.assertCast() - newChild.setTreeLocation(this, slot) - } - } - + newChild.assertDetached() + members.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) + members[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) } override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitClass(this, data) override fun acceptChildren(visitor: IrElementVisitor, data: D) { - nestedInitializers?.accept(visitor, data) members.forEach { it.accept(visitor, data) } } - } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt index 52afee0b356..0c96a7f47ec 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclaration.kt @@ -39,6 +39,7 @@ enum class IrDeclarationKind { CLASS, TYPEALIAS, ENUM_ENTRY, + ANONYMOUS_INITIALIZER, DUMMY; } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrNestedInitializersCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt similarity index 84% rename from compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrNestedInitializersCall.kt rename to compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt index e3089f7245a..683736f8fc6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrNestedInitializersCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrInstanceInitializerCall.kt @@ -20,16 +20,16 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns -interface IrNestedInitializersCall : IrExpression { +interface IrInstanceInitializerCall : IrExpression { val classDescriptor: ClassDescriptor } -class IrNestedInitializersCallImpl( +class IrInstanceInitializerCallImpl( startOffset: Int, endOffset: Int, override val classDescriptor: ClassDescriptor -) : IrTerminalExpressionBase(startOffset, endOffset, classDescriptor.builtIns.unitType), IrNestedInitializersCall { +) : IrTerminalExpressionBase(startOffset, endOffset, classDescriptor.builtIns.unitType), IrInstanceInitializerCall { override fun accept(visitor: IrElementVisitor, data: D): R { - return visitor.visitNestedInitializersCall(this, data) + return visitor.visitInstanceInitializerCall(this, data) } } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt index c990a5b1968..2353e497676 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt @@ -60,15 +60,6 @@ class DumpIrTreeVisitor(out: Appendable): IrElementVisitor { } } - override fun visitClass(declaration: IrClass, data: String) { - declaration.dumpLabeledElementWith(data) { - declaration.nestedInitializers?.accept(this, "nestedInitializers") - declaration.members.forEach { - it.accept(this, "") - } - } - } - override fun visitEnumEntry(declaration: IrEnumEntry, data: String) { declaration.dumpLabeledElementWith(data) { declaration.initializerExpression.accept(this, "init") diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt index 32672e31a0c..529048ad320 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt @@ -69,6 +69,9 @@ class RenderIrElementVisitor : IrElementVisitor { override fun visitEnumEntry(declaration: IrEnumEntry, data: Nothing?): String = "ENUM_ENTRY ${declaration.descriptor.render()}" + override fun visitAnonymousInitializer(declaration: IrAnonymousInitializer, data: Nothing?): String = + "ANONYMOUS_INITIALIZER ${declaration.descriptor.name}" + override fun visitExpressionBody(body: IrExpressionBody, data: Nothing?): String = "EXPRESSION_BODY" @@ -119,8 +122,8 @@ class RenderIrElementVisitor : IrElementVisitor { else enumEntryDescriptor.name } - override fun visitNestedInitializersCall(expression: IrNestedInitializersCall, data: Nothing?): String = - "NESTED_INITIALIZERS_CALL classDescriptor=${expression.classDescriptor.name}" + override fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: Nothing?): String = + "INSTANCE_INITIALIZER_CALL classDescriptor=${expression.classDescriptor.name}" override fun visitGetVariable(expression: IrGetVariable, data: Nothing?): String = "GET_VAR ${expression.descriptor.name} type=${expression.type.render()} operator=${expression.operator}" diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementVisitor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementVisitor.kt index f45137ba715..07850efa0fb 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementVisitor.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementVisitor.kt @@ -39,6 +39,7 @@ interface IrElementVisitor { fun visitVariable(declaration: IrVariable, data: D) = visitDeclaration(declaration, data) fun visitDelegate(declaration: IrDelegate, data: D) = visitDeclaration(declaration, data) fun visitEnumEntry(declaration: IrEnumEntry, data: D) = visitDeclaration(declaration, data) + fun visitAnonymousInitializer(declaration: IrAnonymousInitializer, data: D) = visitDeclaration(declaration, data) fun visitBody(body: IrBody, data: D) = visitElement(body, data) fun visitExpressionBody(body: IrExpressionBody, data: D) = visitBody(body, data) @@ -71,7 +72,7 @@ interface IrElementVisitor { fun visitCallableReference(expression: IrCallableReference, data: D) = visitDeclarationReference(expression, data) fun visitClassReference(expression: IrClassReference, data: D) = visitDeclarationReference(expression, data) - fun visitNestedInitializersCall(expression: IrNestedInitializersCall, data: D) = visitExpression(expression, data) + fun visitInstanceInitializerCall(expression: IrInstanceInitializerCall, data: D) = visitExpression(expression, data) fun visitTypeOperator(expression: IrTypeOperatorCall, data: D) = visitExpression(expression, data) diff --git a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt index 30d4fc714ff..f7514ac3198 100644 --- a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt +++ b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt @@ -6,6 +6,7 @@ FILE /argumentReorderingInDelegatingConstructorCall.kt GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER SET_BACKING_FIELD y type=kotlin.Unit operator=null GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=Base PROPERTY public final val x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -23,8 +24,8 @@ FILE /argumentReorderingInDelegatingConstructorCall.kt CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL x: GET_VAR tmp1_x type=kotlin.Int operator=null y: GET_VAR tmp0_y type=kotlin.Int operator=null + INSTANCE_INITIALIZER_CALL classDescriptor=Test1 CLASS CLASS Test2 - nestedInitializers: BLOCK_BODY CONSTRUCTOR public constructor Test2(/*0*/ xx: kotlin.Int, /*1*/ yy: kotlin.Int) BLOCK_BODY BLOCK type=Base operator=ARGUMENTS_REORDERING_FOR_CALL @@ -36,7 +37,7 @@ FILE /argumentReorderingInDelegatingConstructorCall.kt DELEGATING_CONSTRUCTOR_CALL Base x: GET_VAR tmp1_x type=kotlin.Int operator=null y: GET_VAR tmp0_y type=kotlin.Int operator=null - NESTED_INITIALIZERS_CALL classDescriptor=Test2 + INSTANCE_INITIALIZER_CALL classDescriptor=Test2 CONSTRUCTOR public constructor Test2(/*0*/ xxx: kotlin.Int, /*1*/ yyy: kotlin.Int, /*2*/ a: kotlin.Any) BLOCK_BODY BLOCK type=Test2 operator=ARGUMENTS_REORDERING_FOR_CALL diff --git a/compiler/testData/ir/irText/classes/classMembers.txt b/compiler/testData/ir/irText/classes/classMembers.txt index 53384adcb97..cacede6ab8a 100644 --- a/compiler/testData/ir/irText/classes/classMembers.txt +++ b/compiler/testData/ir/irText/classes/classMembers.txt @@ -8,8 +8,7 @@ FILE /classMembers.kt GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER SET_BACKING_FIELD z type=kotlin.Unit operator=null GET_VAR z type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD property type=kotlin.Unit operator=null - CONST Int type=kotlin.Int value='0' + INSTANCE_INITIALIZER_CALL classDescriptor=C PROPERTY public final val y: kotlin.Int EXPRESSION_BODY GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -52,6 +51,7 @@ FILE /classMembers.kt CLASS CLASS NestedClass CONSTRUCTOR public constructor NestedClass() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=NestedClass FUN public final fun function(): kotlin.Unit BLOCK_BODY CALL .println type=kotlin.Unit operator=null @@ -70,3 +70,4 @@ FILE /classMembers.kt CLASS OBJECT Companion CONSTRUCTOR private constructor Companion() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Companion diff --git a/compiler/testData/ir/irText/classes/classes.txt b/compiler/testData/ir/irText/classes/classes.txt index a75804b1f60..f27de0670e0 100644 --- a/compiler/testData/ir/irText/classes/classes.txt +++ b/compiler/testData/ir/irText/classes/classes.txt @@ -2,17 +2,21 @@ FILE /classes.kt CLASS CLASS TestClass CONSTRUCTOR public constructor TestClass() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=TestClass CLASS INTERFACE TestInterface CLASS OBJECT TestObject CONSTRUCTOR private constructor TestObject() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=TestObject CLASS ANNOTATION_CLASS TestAnnotationClass CONSTRUCTOR public constructor TestAnnotationClass() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=TestAnnotationClass CLASS ENUM_CLASS TestEnumClass CONSTRUCTOR private constructor TestEnumClass() BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super + INSTANCE_INITIALIZER_CALL classDescriptor=TestEnumClass FUN public final /*synthesized*/ fun values(): kotlin.Array SYNTHETIC_BODY kind=ENUM_VALUES FUN public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): TestEnumClass diff --git a/compiler/testData/ir/irText/classes/companionObject.txt b/compiler/testData/ir/irText/classes/companionObject.txt index 37fe1c9419f..f0ffc85c217 100644 --- a/compiler/testData/ir/irText/classes/companionObject.txt +++ b/compiler/testData/ir/irText/classes/companionObject.txt @@ -2,12 +2,16 @@ FILE /companionObject.kt CLASS CLASS Test1 CONSTRUCTOR public constructor Test1() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Test1 CLASS OBJECT Companion CONSTRUCTOR private constructor Companion() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Companion CLASS CLASS Test2 CONSTRUCTOR public constructor Test2() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Test2 CLASS OBJECT Named CONSTRUCTOR private constructor Named() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Named diff --git a/compiler/testData/ir/irText/classes/dataClasses.txt b/compiler/testData/ir/irText/classes/dataClasses.txt index b71d7b67b6b..f078977c01a 100644 --- a/compiler/testData/ir/irText/classes/dataClasses.txt +++ b/compiler/testData/ir/irText/classes/dataClasses.txt @@ -8,6 +8,7 @@ FILE /dataClasses.kt GET_VAR y type=kotlin.String operator=INITIALIZE_PROPERTY_FROM_PARAMETER SET_BACKING_FIELD z type=kotlin.Unit operator=null GET_VAR z type=kotlin.Any operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=Test1 PROPERTY public final val x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER diff --git a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.txt b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.txt index 7009e9a026f..13fe4f4a6c1 100644 --- a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.txt +++ b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.txt @@ -2,16 +2,16 @@ FILE /delegatingConstructorCallsInSecondaryConstructors.kt CLASS CLASS Base CONSTRUCTOR public constructor Base() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Base CLASS CLASS Test - nestedInitializers: BLOCK_BODY CONSTRUCTOR public constructor Test() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Base - NESTED_INITIALIZERS_CALL classDescriptor=Test + INSTANCE_INITIALIZER_CALL classDescriptor=Test CONSTRUCTOR public constructor Test(/*0*/ xx: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Base - NESTED_INITIALIZERS_CALL classDescriptor=Test + INSTANCE_INITIALIZER_CALL classDescriptor=Test CONSTRUCTOR public constructor Test(/*0*/ xx: kotlin.Short) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Test diff --git a/compiler/testData/ir/irText/classes/enum.txt b/compiler/testData/ir/irText/classes/enum.txt index 5b473b75407..c34dca3175b 100644 --- a/compiler/testData/ir/irText/classes/enum.txt +++ b/compiler/testData/ir/irText/classes/enum.txt @@ -3,6 +3,7 @@ FILE /enum.kt CONSTRUCTOR private constructor TestEnum1() BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super + INSTANCE_INITIALIZER_CALL classDescriptor=TestEnum1 ENUM_ENTRY enum entry TEST1 init: ENUM_CONSTRUCTOR_CALL TestEnum1 TEST1 ENUM_ENTRY enum entry TEST2 @@ -17,6 +18,7 @@ FILE /enum.kt ENUM_CONSTRUCTOR_CALL Enum super SET_BACKING_FIELD x type=kotlin.Unit operator=null GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=TestEnum2 PROPERTY public final val x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -37,12 +39,14 @@ FILE /enum.kt CONSTRUCTOR private constructor TestEnum3() BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super + INSTANCE_INITIALIZER_CALL classDescriptor=TestEnum3 ENUM_ENTRY enum entry TEST init: ENUM_CONSTRUCTOR_CALL TEST TEST class: CLASS ENUM_ENTRY TEST CONSTRUCTOR private constructor TEST() BLOCK_BODY ENUM_CONSTRUCTOR_CALL TestEnum3 super + INSTANCE_INITIALIZER_CALL classDescriptor=TEST FUN public open override /*1*/ fun foo(): kotlin.Unit BLOCK_BODY CALL .println type=kotlin.Unit operator=null @@ -58,6 +62,7 @@ FILE /enum.kt ENUM_CONSTRUCTOR_CALL Enum super SET_BACKING_FIELD x type=kotlin.Unit operator=null GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=TestEnum4 PROPERTY public final val x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -68,6 +73,7 @@ FILE /enum.kt BLOCK_BODY ENUM_CONSTRUCTOR_CALL TestEnum4 super x: CONST Int type=kotlin.Int value='1' + INSTANCE_INITIALIZER_CALL classDescriptor=TEST1 FUN public open override /*1*/ fun foo(): kotlin.Unit BLOCK_BODY CALL .println type=kotlin.Unit operator=null @@ -79,11 +85,13 @@ FILE /enum.kt BLOCK_BODY ENUM_CONSTRUCTOR_CALL TestEnum4 super x: CONST Int type=kotlin.Int value='2' - BLOCK type=kotlin.Unit operator=null - SET_BACKING_FIELD z type=kotlin.Unit operator=null - CALL . type=kotlin.Int operator=GET_PROPERTY - $this: THIS enum entry TEST2 type=TestEnum4.TEST2 + INSTANCE_INITIALIZER_CALL classDescriptor=TEST2 PROPERTY public final val z: kotlin.Int + ANONYMOUS_INITIALIZER TEST2 + BLOCK_BODY + SET_BACKING_FIELD z type=kotlin.Unit operator=null + CALL . type=kotlin.Int operator=GET_PROPERTY + $this: THIS enum entry TEST2 type=TestEnum4.TEST2 FUN public open override /*1*/ fun foo(): kotlin.Unit BLOCK_BODY CALL .println type=kotlin.Unit operator=null diff --git a/compiler/testData/ir/irText/classes/initBlock.kt b/compiler/testData/ir/irText/classes/initBlock.kt new file mode 100644 index 00000000000..f6c5d646e12 --- /dev/null +++ b/compiler/testData/ir/irText/classes/initBlock.kt @@ -0,0 +1,31 @@ +class Test1 { + init { + println() + } +} + +class Test2(val x: Int) { + init { + println() + } +} + +class Test3 { + init { + println() + } + + constructor() +} + +class Test4 { + init { + println("1") + } + + constructor() + + init { + println("2") + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/classes/initBlock.txt b/compiler/testData/ir/irText/classes/initBlock.txt new file mode 100644 index 00000000000..6862c75b19f --- /dev/null +++ b/compiler/testData/ir/irText/classes/initBlock.txt @@ -0,0 +1,41 @@ +FILE /initBlock.kt + CLASS CLASS Test1 + CONSTRUCTOR public constructor Test1() + BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Test1 + ANONYMOUS_INITIALIZER Test1 + BLOCK_BODY + CALL .println type=kotlin.Unit operator=null + CLASS CLASS Test2 + CONSTRUCTOR public constructor Test2(/*0*/ x: kotlin.Int) + BLOCK_BODY + SET_BACKING_FIELD x type=kotlin.Unit operator=null + GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=Test2 + PROPERTY public final val x: kotlin.Int + EXPRESSION_BODY + GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + ANONYMOUS_INITIALIZER Test2 + BLOCK_BODY + CALL .println type=kotlin.Unit operator=null + CLASS CLASS Test3 + ANONYMOUS_INITIALIZER Test3 + BLOCK_BODY + CALL .println type=kotlin.Unit operator=null + CONSTRUCTOR public constructor Test3() + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL Any + INSTANCE_INITIALIZER_CALL classDescriptor=Test3 + CLASS CLASS Test4 + ANONYMOUS_INITIALIZER Test4 + BLOCK_BODY + CALL .println type=kotlin.Unit operator=null + message: CONST String type=kotlin.String value='1' + CONSTRUCTOR public constructor Test4() + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL Any + INSTANCE_INITIALIZER_CALL classDescriptor=Test4 + ANONYMOUS_INITIALIZER Test4 + BLOCK_BODY + CALL .println type=kotlin.Unit operator=null + message: CONST String type=kotlin.String value='2' diff --git a/compiler/testData/ir/irText/classes/initVal.txt b/compiler/testData/ir/irText/classes/initVal.txt index 70d3b87cf65..e4739db70c1 100644 --- a/compiler/testData/ir/irText/classes/initVal.txt +++ b/compiler/testData/ir/irText/classes/initVal.txt @@ -4,21 +4,23 @@ FILE /initVal.kt BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitValFromParameter PROPERTY public final val x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER CLASS CLASS TestInitValInClass CONSTRUCTOR public constructor TestInitValInClass() BLOCK_BODY - SET_BACKING_FIELD x type=kotlin.Unit operator=null - CONST Int type=kotlin.Int value='0' + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitValInClass PROPERTY public final val x: kotlin.Int = 0 EXPRESSION_BODY CONST Int type=kotlin.Int value='0' CLASS CLASS TestInitValInInitBlock CONSTRUCTOR public constructor TestInitValInInitBlock() BLOCK_BODY - BLOCK type=kotlin.Unit operator=null - SET_BACKING_FIELD x type=kotlin.Unit operator=null - CONST Int type=kotlin.Int value='0' + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitValInInitBlock PROPERTY public final val x: kotlin.Int + ANONYMOUS_INITIALIZER TestInitValInInitBlock + BLOCK_BODY + SET_BACKING_FIELD x type=kotlin.Unit operator=null + CONST Int type=kotlin.Int value='0' diff --git a/compiler/testData/ir/irText/classes/initVar.txt b/compiler/testData/ir/irText/classes/initVar.txt index 249ba149164..dd95cc69327 100644 --- a/compiler/testData/ir/irText/classes/initVar.txt +++ b/compiler/testData/ir/irText/classes/initVar.txt @@ -4,30 +4,31 @@ FILE /initVar.kt BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitVarFromParameter PROPERTY public final var x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER CLASS CLASS TestInitVarInClass CONSTRUCTOR public constructor TestInitVarInClass() BLOCK_BODY - SET_BACKING_FIELD x type=kotlin.Unit operator=null - CONST Int type=kotlin.Int value='0' + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitVarInClass PROPERTY public final var x: kotlin.Int EXPRESSION_BODY CONST Int type=kotlin.Int value='0' CLASS CLASS TestInitVarInInitBlock CONSTRUCTOR public constructor TestInitVarInInitBlock() BLOCK_BODY - BLOCK type=kotlin.Unit operator=null - CALL . type=kotlin.Unit operator=EQ - $this: THIS public final class TestInitVarInInitBlock type=TestInitVarInInitBlock - : CONST Int type=kotlin.Int value='0' + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitVarInInitBlock PROPERTY public final var x: kotlin.Int + ANONYMOUS_INITIALIZER TestInitVarInInitBlock + BLOCK_BODY + CALL . type=kotlin.Unit operator=EQ + $this: THIS public final class TestInitVarInInitBlock type=TestInitVarInInitBlock + : CONST Int type=kotlin.Int value='0' CLASS CLASS TestInitVarWithCustomSetter CONSTRUCTOR public constructor TestInitVarWithCustomSetter() BLOCK_BODY - SET_BACKING_FIELD x type=kotlin.Unit operator=null - CONST Int type=kotlin.Int value='0' + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitVarWithCustomSetter PROPERTY public final var x: kotlin.Int EXPRESSION_BODY CONST Int type=kotlin.Int value='0' @@ -36,22 +37,21 @@ FILE /initVar.kt SET_BACKING_FIELD x type=kotlin.Unit operator=EQ GET_VAR value type=kotlin.Int operator=null CLASS CLASS TestInitVarWithCustomSetterWithExplicitCtor - nestedInitializers: BLOCK_BODY - BLOCK type=kotlin.Unit operator=null - CALL . type=kotlin.Unit operator=EQ - $this: THIS public final class TestInitVarWithCustomSetterWithExplicitCtor type=TestInitVarWithCustomSetterWithExplicitCtor - value: CONST Int type=kotlin.Int value='0' PROPERTY public final var x: kotlin.Int PROPERTY_SETTER public final fun (/*0*/ value: kotlin.Int): kotlin.Unit BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=EQ GET_VAR value type=kotlin.Int operator=null + ANONYMOUS_INITIALIZER TestInitVarWithCustomSetterWithExplicitCtor + BLOCK_BODY + CALL . type=kotlin.Unit operator=EQ + $this: THIS public final class TestInitVarWithCustomSetterWithExplicitCtor type=TestInitVarWithCustomSetterWithExplicitCtor + value: CONST Int type=kotlin.Int value='0' CONSTRUCTOR public constructor TestInitVarWithCustomSetterWithExplicitCtor() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Any - NESTED_INITIALIZERS_CALL classDescriptor=TestInitVarWithCustomSetterWithExplicitCtor + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitVarWithCustomSetterWithExplicitCtor CLASS CLASS TestInitVarWithCustomSetterInCtor - nestedInitializers: BLOCK_BODY PROPERTY public final var x: kotlin.Int PROPERTY_SETTER public final fun (/*0*/ value: kotlin.Int): kotlin.Unit BLOCK_BODY @@ -60,7 +60,7 @@ FILE /initVar.kt CONSTRUCTOR public constructor TestInitVarWithCustomSetterInCtor() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Any - NESTED_INITIALIZERS_CALL classDescriptor=TestInitVarWithCustomSetterInCtor + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitVarWithCustomSetterInCtor CALL . type=kotlin.Unit operator=EQ $this: THIS public final class TestInitVarWithCustomSetterInCtor type=TestInitVarWithCustomSetterInCtor value: CONST Int type=kotlin.Int value='42' diff --git a/compiler/testData/ir/irText/classes/localClasses.txt b/compiler/testData/ir/irText/classes/localClasses.txt index b61d75af82d..f4c97f49653 100644 --- a/compiler/testData/ir/irText/classes/localClasses.txt +++ b/compiler/testData/ir/irText/classes/localClasses.txt @@ -4,6 +4,7 @@ FILE /localClasses.kt CLASS CLASS LocalClass CONSTRUCTOR public constructor LocalClass() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=LocalClass FUN public final fun foo(): kotlin.Unit BLOCK_BODY CALL .foo type=kotlin.Unit operator=null diff --git a/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt b/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt index 618359f561a..dd8c3ba2274 100644 --- a/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt +++ b/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt @@ -7,6 +7,7 @@ FILE /objectLiteralExpressions.kt CLASS CLASS CONSTRUCTOR public constructor () BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor= CALL . type=test1. operator=OBJECT_LITERAL PROPERTY public val test2: IFoo EXPRESSION_BODY @@ -14,6 +15,7 @@ FILE /objectLiteralExpressions.kt CLASS CLASS CONSTRUCTOR public constructor () BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor= FUN public open override /*1*/ fun foo(): kotlin.Unit BLOCK_BODY CALL .println type=kotlin.Unit operator=null @@ -22,9 +24,11 @@ FILE /objectLiteralExpressions.kt CLASS CLASS Outer CONSTRUCTOR public constructor Outer() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Outer CLASS CLASS Inner CONSTRUCTOR public constructor Inner() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Inner FUN public final fun test3(): Outer.Inner BLOCK_BODY RETURN type=kotlin.Nothing from=test3 @@ -34,6 +38,7 @@ FILE /objectLiteralExpressions.kt BLOCK_BODY CALL . type=Outer.Inner operator=SUPER_CONSTRUCTOR_CALL $this: THIS public final class Outer type=Outer + INSTANCE_INITIALIZER_CALL classDescriptor= FUN public open override /*1*/ fun foo(): kotlin.Unit BLOCK_BODY CALL .println type=kotlin.Unit operator=null @@ -48,6 +53,7 @@ FILE /objectLiteralExpressions.kt BLOCK_BODY CALL . type=Outer.Inner operator=SUPER_CONSTRUCTOR_CALL $this: $RECEIVER of: test4 type=Outer + INSTANCE_INITIALIZER_CALL classDescriptor= FUN public open override /*1*/ fun foo(): kotlin.Unit BLOCK_BODY CALL .println type=kotlin.Unit operator=null diff --git a/compiler/testData/ir/irText/classes/primaryConstructor.txt b/compiler/testData/ir/irText/classes/primaryConstructor.txt index 04e85bc6d68..573dae23a5f 100644 --- a/compiler/testData/ir/irText/classes/primaryConstructor.txt +++ b/compiler/testData/ir/irText/classes/primaryConstructor.txt @@ -6,6 +6,7 @@ FILE /primaryConstructor.kt GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER SET_BACKING_FIELD y type=kotlin.Unit operator=null GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=Test1 PROPERTY public final val x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -17,8 +18,7 @@ FILE /primaryConstructor.kt BLOCK_BODY SET_BACKING_FIELD y type=kotlin.Unit operator=null GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - SET_BACKING_FIELD x type=kotlin.Unit operator=null - GET_VAR x type=kotlin.Int operator=null + INSTANCE_INITIALIZER_CALL classDescriptor=Test2 PROPERTY public final val y: kotlin.Int EXPRESSION_BODY GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -30,10 +30,12 @@ FILE /primaryConstructor.kt BLOCK_BODY SET_BACKING_FIELD y type=kotlin.Unit operator=null GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - BLOCK type=kotlin.Unit operator=null - SET_BACKING_FIELD x type=kotlin.Unit operator=null - GET_VAR x type=kotlin.Int operator=null + INSTANCE_INITIALIZER_CALL classDescriptor=Test3 PROPERTY public final val y: kotlin.Int EXPRESSION_BODY GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER PROPERTY public final val x: kotlin.Int + ANONYMOUS_INITIALIZER Test3 + BLOCK_BODY + SET_BACKING_FIELD x type=kotlin.Unit operator=null + GET_VAR x type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt index 452bb8f0501..a333b9b6e01 100644 --- a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt +++ b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt @@ -2,14 +2,17 @@ FILE /primaryConstructorWithSuperConstructorCall.kt CLASS CLASS Base CONSTRUCTOR public constructor Base() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Base CLASS CLASS TestImplicitPrimaryConstructor CONSTRUCTOR public constructor TestImplicitPrimaryConstructor() BLOCK_BODY CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL + INSTANCE_INITIALIZER_CALL classDescriptor=TestImplicitPrimaryConstructor CLASS CLASS TestExplicitPrimaryConstructor CONSTRUCTOR public constructor TestExplicitPrimaryConstructor() BLOCK_BODY CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL + INSTANCE_INITIALIZER_CALL classDescriptor=TestExplicitPrimaryConstructor CLASS CLASS TestWithDelegatingConstructor CONSTRUCTOR public constructor TestWithDelegatingConstructor(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) BLOCK_BODY @@ -18,6 +21,7 @@ FILE /primaryConstructorWithSuperConstructorCall.kt GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER SET_BACKING_FIELD y type=kotlin.Unit operator=null GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=TestWithDelegatingConstructor PROPERTY public final val x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER diff --git a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.txt b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.txt index aba929fdafe..f6bf083a0bc 100644 --- a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.txt +++ b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.txt @@ -18,6 +18,7 @@ FILE /qualifiedSuperCalls.kt CLASS CLASS CBoth CONSTRUCTOR public constructor CBoth() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=CBoth FUN public open override /*2*/ fun foo(): kotlin.Unit BLOCK_BODY CALL .foo superQualifier=ILeft type=kotlin.Unit operator=null diff --git a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.txt b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.txt index 688a8f63181..02bb8c20309 100644 --- a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.txt +++ b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.txt @@ -2,24 +2,22 @@ FILE /secondaryConstructorWithInitializersFromClassBody.kt CLASS CLASS Base CONSTRUCTOR public constructor Base() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Base CLASS CLASS TestProperty - nestedInitializers: BLOCK_BODY - SET_BACKING_FIELD x type=kotlin.Unit operator=null - CONST Int type=kotlin.Int value='0' PROPERTY public final val x: kotlin.Int = 0 EXPRESSION_BODY CONST Int type=kotlin.Int value='0' CONSTRUCTOR public constructor TestProperty() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Base - NESTED_INITIALIZERS_CALL classDescriptor=TestProperty + INSTANCE_INITIALIZER_CALL classDescriptor=TestProperty CLASS CLASS TestInitBlock - nestedInitializers: BLOCK_BODY - BLOCK type=kotlin.Unit operator=null + PROPERTY public final val x: kotlin.Int + ANONYMOUS_INITIALIZER TestInitBlock + BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null CONST Int type=kotlin.Int value='0' - PROPERTY public final val x: kotlin.Int CONSTRUCTOR public constructor TestInitBlock() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Base - NESTED_INITIALIZERS_CALL classDescriptor=TestInitBlock + INSTANCE_INITIALIZER_CALL classDescriptor=TestInitBlock diff --git a/compiler/testData/ir/irText/classes/secondaryConstructors.txt b/compiler/testData/ir/irText/classes/secondaryConstructors.txt index d1cc6373d93..72c6480821f 100644 --- a/compiler/testData/ir/irText/classes/secondaryConstructors.txt +++ b/compiler/testData/ir/irText/classes/secondaryConstructors.txt @@ -1,6 +1,5 @@ FILE /secondaryConstructors.kt CLASS CLASS C - nestedInitializers: BLOCK_BODY CONSTRUCTOR public constructor C() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL C @@ -8,4 +7,4 @@ FILE /secondaryConstructors.kt CONSTRUCTOR public constructor C(/*0*/ x: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Any - NESTED_INITIALIZERS_CALL classDescriptor=C + INSTANCE_INITIALIZER_CALL classDescriptor=C diff --git a/compiler/testData/ir/irText/classes/superCalls.txt b/compiler/testData/ir/irText/classes/superCalls.txt index 14cdefc436e..579ab830c9a 100644 --- a/compiler/testData/ir/irText/classes/superCalls.txt +++ b/compiler/testData/ir/irText/classes/superCalls.txt @@ -2,8 +2,7 @@ FILE /superCalls.kt CLASS CLASS Base CONSTRUCTOR public constructor Base() BLOCK_BODY - SET_BACKING_FIELD bar type=kotlin.Unit operator=null - CONST String type=kotlin.String value='' + INSTANCE_INITIALIZER_CALL classDescriptor=Base FUN public open fun foo(): kotlin.Unit BLOCK_BODY PROPERTY public open val bar: kotlin.String = "" @@ -13,6 +12,7 @@ FILE /superCalls.kt CONSTRUCTOR public constructor Derived() BLOCK_BODY CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL + INSTANCE_INITIALIZER_CALL classDescriptor=Derived FUN public open override /*1*/ fun foo(): kotlin.Unit BLOCK_BODY CALL .foo superQualifier=Base type=kotlin.Unit operator=null diff --git a/compiler/testData/ir/irText/declarations/delegatedProperties.txt b/compiler/testData/ir/irText/declarations/delegatedProperties.txt index a36eaa12872..2344fefd47c 100644 --- a/compiler/testData/ir/irText/declarations/delegatedProperties.txt +++ b/compiler/testData/ir/irText/declarations/delegatedProperties.txt @@ -21,6 +21,7 @@ FILE /delegatedProperties.kt BLOCK_BODY SET_BACKING_FIELD map type=kotlin.Unit operator=null GET_VAR map type=kotlin.collections.MutableMap operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=C PROPERTY public final val map: kotlin.collections.MutableMap EXPRESSION_BODY GET_VAR map type=kotlin.collections.MutableMap operator=INITIALIZE_PROPERTY_FROM_PARAMETER diff --git a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt index ee96143dff4..3e090734a12 100644 --- a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt +++ b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt @@ -16,6 +16,7 @@ FILE /arrayAugmentedAssignment1.kt BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null GET_VAR x type=kotlin.IntArray operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=C PROPERTY public final val x: kotlin.IntArray EXPRESSION_BODY GET_VAR x type=kotlin.IntArray operator=INITIALIZE_PROPERTY_FROM_PARAMETER diff --git a/compiler/testData/ir/irText/expressions/assignments.txt b/compiler/testData/ir/irText/expressions/assignments.txt index 541ef63633b..d5add9d3de2 100644 --- a/compiler/testData/ir/irText/expressions/assignments.txt +++ b/compiler/testData/ir/irText/expressions/assignments.txt @@ -4,6 +4,7 @@ FILE /assignments.kt BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=Ref PROPERTY public final var x: kotlin.Int EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER diff --git a/compiler/testData/ir/irText/expressions/augmentedAssignment2.txt b/compiler/testData/ir/irText/expressions/augmentedAssignment2.txt index 863e9287e5b..61af9081f89 100644 --- a/compiler/testData/ir/irText/expressions/augmentedAssignment2.txt +++ b/compiler/testData/ir/irText/expressions/augmentedAssignment2.txt @@ -2,6 +2,7 @@ FILE /augmentedAssignment2.kt CLASS CLASS A CONSTRUCTOR public constructor A() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=A FUN public operator fun A.plusAssign(/*0*/ s: kotlin.String): kotlin.Unit BLOCK_BODY FUN public operator fun A.minusAssign(/*0*/ s: kotlin.String): kotlin.Unit diff --git a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt index 11e1dbf6def..79343972834 100644 --- a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt +++ b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt @@ -2,6 +2,7 @@ FILE /chainOfSafeCalls.kt CLASS CLASS C CONSTRUCTOR public constructor C() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=C FUN public final fun foo(): C BLOCK_BODY RETURN type=kotlin.Nothing from=foo diff --git a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt index 10d3bdcae68..17f02bc7735 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt @@ -2,11 +2,13 @@ FILE /forWithImplicitReceivers.kt CLASS OBJECT FiveTimes CONSTRUCTOR private constructor FiveTimes() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=FiveTimes CLASS CLASS IntCell CONSTRUCTOR public constructor IntCell(/*0*/ value: kotlin.Int) BLOCK_BODY SET_BACKING_FIELD value type=kotlin.Unit operator=null GET_VAR value type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=IntCell PROPERTY public final var value: kotlin.Int EXPRESSION_BODY GET_VAR value type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER diff --git a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt index 51b8d5135a6..238ee2ca4cc 100644 --- a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt +++ b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt @@ -23,19 +23,7 @@ FILE /jvmStaticFieldReference.kt CLASS CLASS TestClass CONSTRUCTOR public constructor TestClass() BLOCK_BODY - SET_BACKING_FIELD test type=kotlin.Unit operator=null - WHEN type=kotlin.Int operator=WHEN - else: BLOCK type=kotlin.Int operator=null - CALL .println type=kotlin.Unit operator=null - $this: TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream - CALL . type=java.io.PrintStream! operator=GET_PROPERTY - p0: CONST String type=kotlin.String value='TestClass/test' - CONST Int type=kotlin.Int value='42' - BLOCK type=kotlin.Unit operator=null - CALL .println type=kotlin.Unit operator=null - $this: TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream - CALL . type=java.io.PrintStream! operator=GET_PROPERTY - p0: CONST String type=kotlin.String value='TestClass/init' + INSTANCE_INITIALIZER_CALL classDescriptor=TestClass PROPERTY public final val test: kotlin.Int EXPRESSION_BODY WHEN type=kotlin.Int operator=WHEN @@ -45,3 +33,9 @@ FILE /jvmStaticFieldReference.kt CALL . type=java.io.PrintStream! operator=GET_PROPERTY p0: CONST String type=kotlin.String value='TestClass/test' CONST Int type=kotlin.Int value='42' + ANONYMOUS_INITIALIZER TestClass + BLOCK_BODY + CALL .println type=kotlin.Unit operator=null + $this: TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + CALL . type=java.io.PrintStream! operator=GET_PROPERTY + p0: CONST String type=kotlin.String value='TestClass/init' diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt index 5836b8ebf6c..f7e0db28df1 100644 --- a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt @@ -2,6 +2,7 @@ FILE /safeCallWithIncrementDecrement.kt CLASS CLASS C CONSTRUCTOR public constructor C() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=C PROPERTY public var test.C?.p: kotlin.Int PROPERTY_GETTER public fun test.C?.(): kotlin.Int BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/safeCalls.txt b/compiler/testData/ir/irText/expressions/safeCalls.txt index f8168b930e7..4ebf2509452 100644 --- a/compiler/testData/ir/irText/expressions/safeCalls.txt +++ b/compiler/testData/ir/irText/expressions/safeCalls.txt @@ -4,6 +4,7 @@ FILE /safeCalls.kt BLOCK_BODY SET_BACKING_FIELD value type=kotlin.Unit operator=null GET_VAR value type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER + INSTANCE_INITIALIZER_CALL classDescriptor=Ref PROPERTY public final var value: kotlin.Int EXPRESSION_BODY GET_VAR value type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER diff --git a/compiler/testData/ir/irText/expressions/values.txt b/compiler/testData/ir/irText/expressions/values.txt index 9496a326946..655fdbdcfb3 100644 --- a/compiler/testData/ir/irText/expressions/values.txt +++ b/compiler/testData/ir/irText/expressions/values.txt @@ -3,6 +3,7 @@ FILE /values.kt CONSTRUCTOR private constructor Enum() BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super + INSTANCE_INITIALIZER_CALL classDescriptor=Enum ENUM_ENTRY enum entry A init: ENUM_CONSTRUCTOR_CALL Enum A FUN public final /*synthesized*/ fun values(): kotlin.Array @@ -12,15 +13,18 @@ FILE /values.kt CLASS OBJECT A CONSTRUCTOR private constructor A() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=A PROPERTY public val a: kotlin.Int = 0 EXPRESSION_BODY CONST Int type=kotlin.Int value='0' CLASS CLASS Z CONSTRUCTOR public constructor Z() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Z CLASS OBJECT Companion CONSTRUCTOR private constructor Companion() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=Companion FUN public fun test1(): Enum BLOCK_BODY RETURN type=kotlin.Nothing from=test1 diff --git a/compiler/testData/ir/irText/expressions/when.txt b/compiler/testData/ir/irText/expressions/when.txt index 50f15c36e37..b30e3e4d079 100644 --- a/compiler/testData/ir/irText/expressions/when.txt +++ b/compiler/testData/ir/irText/expressions/when.txt @@ -2,6 +2,7 @@ FILE /when.kt CLASS OBJECT A CONSTRUCTOR private constructor A() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=A FUN public fun testWithSubject(/*0*/ x: kotlin.Any?): kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from=testWithSubject diff --git a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt index f13c346e2e5..55bff8463a6 100644 --- a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt +++ b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt @@ -2,9 +2,11 @@ FILE /multipleImplicitReceivers.kt CLASS OBJECT A CONSTRUCTOR private constructor A() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=A CLASS OBJECT B CONSTRUCTOR private constructor B() BLOCK_BODY + INSTANCE_INITIALIZER_CALL classDescriptor=B CLASS INTERFACE IFoo PROPERTY public open val A.foo: B PROPERTY_GETTER public open fun A.(): B diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 180c4dc670a..9505087a8e3 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -85,6 +85,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { doTest(fileName); } + @TestMetadata("initBlock.kt") + public void testInitBlock() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/classes/initBlock.kt"); + doTest(fileName); + } + @TestMetadata("initVal.kt") public void testInitVal() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/classes/initVal.kt");