From 865d2c43c709c4c5a27733576a4b86bbcbfcfd82 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 31 Aug 2016 18:28:04 +0300 Subject: [PATCH] Default arguments stored in function declarations. --- .../kotlin/psi2ir/generators/BodyGenerator.kt | 15 ++++++++ .../psi2ir/generators/ClassGenerator.kt | 10 +++-- .../psi2ir/generators/DeclarationGenerator.kt | 30 +++++++++------ .../generators/LocalFunctionGenerator.kt | 4 +- .../src/org/jetbrains/kotlin/ir/IrSlots.kt | 2 +- .../{IrFunction.kt => IrGeneralFunction.kt} | 37 +++++++++++++++++-- .../ir/declarations/IrPropertyAccessor.kt | 4 +- .../jetbrains/kotlin/ir/util/DumpIrTree.kt | 21 +++++++++-- .../kotlin/ir/util/RenderIrElement.kt | 3 ++ .../kotlin/ir/visitors/IrElementVisitor.kt | 9 +++-- ...tReorderingInDelegatingConstructorCall.txt | 8 ++-- .../ir/irText/classes/classMembers.txt | 10 +++-- .../testData/ir/irText/classes/classes.txt | 8 ++-- .../ir/irText/classes/companionObject.txt | 8 ++-- .../ir/irText/classes/dataClasses.txt | 2 +- ...onstructorCallsInSecondaryConstructors.txt | 8 ++-- compiler/testData/ir/irText/classes/enum.txt | 14 +++---- .../testData/ir/irText/classes/initVal.txt | 6 +-- .../testData/ir/irText/classes/initVar.txt | 12 +++--- .../ir/irText/classes/localClasses.txt | 2 +- .../classes/objectLiteralExpressions.txt | 12 +++--- .../ir/irText/classes/primaryConstructor.txt | 6 +-- ...aryConstructorWithSuperConstructorCall.txt | 10 ++--- .../ir/irText/classes/qualifiedSuperCalls.txt | 2 +- ...nstructorWithInitializersFromClassBody.txt | 6 +-- .../irText/classes/secondaryConstructors.txt | 4 +- .../testData/ir/irText/classes/superCalls.txt | 4 +- .../testData/ir/irText/defaultArguments.kt | 1 + .../testData/ir/irText/defaultArguments.txt | 7 ++++ .../expressions/arrayAugmentedAssignment1.txt | 2 +- .../ir/irText/expressions/assignments.txt | 2 +- .../expressions/augmentedAssignment2.txt | 2 +- .../irText/expressions/chainOfSafeCalls.txt | 2 +- .../expressions/forWithImplicitReceivers.txt | 4 +- .../expressions/jvmStaticFieldReference.txt | 2 +- .../safeCallWithIncrementDecrement.txt | 2 +- .../ir/irText/expressions/safeCalls.txt | 2 +- .../testData/ir/irText/expressions/values.txt | 8 ++-- .../testData/ir/irText/expressions/when.txt | 2 +- .../lambdas/multipleImplicitReceivers.txt | 4 +- .../kotlin/ir/IrTextTestCaseGenerated.java | 6 +++ 41 files changed, 197 insertions(+), 106 deletions(-) rename compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/{IrFunction.kt => IrGeneralFunction.kt} (66%) create mode 100644 compiler/testData/ir/irText/defaultArguments.kt create mode 100644 compiler/testData/ir/irText/defaultArguments.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 293166ee7df..f2a7e47a9b9 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 @@ -19,6 +19,7 @@ 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.expressions.* import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset @@ -30,6 +31,20 @@ class BodyGenerator(val scopeOwner: DeclarationDescriptor, override val context: override val scope = Scope(scopeOwner) private val loopTable = HashMap() + fun generateDefaultParameters(ktFunction: KtFunction, irFunction: IrFunctionBase) { + generateDefaultParameters(ktFunction.valueParameterList ?: return, irFunction) + } + + fun generateDefaultParameters(ktParameterList: KtParameterList, irFunction: IrFunctionBase) { + val statementGenerator = createStatementGenerator() + for (ktParameter in ktParameterList.parameters) { + val ktDefaultValue = ktParameter.defaultValue ?: continue + val valueParameter = getOrFail(BindingContext.VALUE_PARAMETER, ktParameter) as? ValueParameterDescriptor ?: continue + val irDefaultValue = statementGenerator.generateExpression(ktDefaultValue) + irFunction.putDefault(valueParameter, IrExpressionBodyImpl(ktDefaultValue.startOffset, ktDefaultValue.endOffset, irDefaultValue)) + } + } + fun generateFunctionBody(ktBody: KtExpression): IrBody { val statementGenerator = createStatementGenerator() 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 4ae425d862f..c9817ac7e02 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 @@ -72,10 +72,14 @@ class ClassGenerator(val declarationGenerator: DeclarationGenerator) : Generator private fun generatePrimaryConstructor(irClass: IrClassImpl, ktClassOrObject: KtClassOrObject) { val primaryConstructorDescriptor = irClass.descriptor.unsubstitutedPrimaryConstructor ?: return - val irPrimaryConstructor = IrFunctionImpl(ktClassOrObject.startOffset, ktClassOrObject.endOffset, IrDeclarationOrigin.DEFINED, - primaryConstructorDescriptor) + val irPrimaryConstructor = IrConstructorImpl(ktClassOrObject.startOffset, ktClassOrObject.endOffset, IrDeclarationOrigin.DEFINED, + primaryConstructorDescriptor) - irPrimaryConstructor.body = BodyGenerator(primaryConstructorDescriptor, context).generatePrimaryConstructorBody(ktClassOrObject) + val bodyGenerator = BodyGenerator(primaryConstructorDescriptor, context) + ktClassOrObject.getPrimaryConstructor()?.valueParameterList?.let { ktValueParameterList -> + bodyGenerator.generateDefaultParameters(ktValueParameterList, irPrimaryConstructor) + } + irPrimaryConstructor.body = bodyGenerator.generatePrimaryConstructorBody(ktClassOrObject) irClass.addMember(irPrimaryConstructor) } 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 5182eb31c07..8aa5978b274 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 @@ -57,29 +57,35 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator { IrTypeAliasImpl(ktDeclaration.startOffset, ktDeclaration.endOffset, IrDeclarationOrigin.DEFINED, getOrFail(BindingContext.TYPE_ALIAS, ktDeclaration)) - fun generateFunctionDeclaration(ktFunction: KtNamedFunction): IrFunction { + fun generateFunctionDeclaration(ktFunction: KtNamedFunction): IrGeneralFunction { val functionDescriptor = getOrFail(BindingContext.FUNCTION, ktFunction) - val body = ktFunction.bodyExpression?.let { generateFunctionBody(functionDescriptor, it) } - return IrFunctionImpl(ktFunction.startOffset, ktFunction.endOffset, IrDeclarationOrigin.DEFINED, - functionDescriptor, body) + val irFunction = IrFunctionImpl(ktFunction.startOffset, ktFunction.endOffset, IrDeclarationOrigin.DEFINED, functionDescriptor) + val bodyGenerator = createBodyGenerator(functionDescriptor) + bodyGenerator.generateDefaultParameters(ktFunction, irFunction) + irFunction.body = ktFunction.bodyExpression?.let { bodyGenerator.generateFunctionBody(it) } + return irFunction } - fun generateSecondaryConstructor(ktConstructor: KtSecondaryConstructor) : IrFunction { + fun generateSecondaryConstructor(ktConstructor: KtSecondaryConstructor) : IrGeneralFunction { if (ktConstructor.isConstructorDelegatingToSuper(context.bindingContext)) { return generateSecondaryConstructorWithNestedInitializers(ktConstructor) } val constructorDescriptor = getOrFail(BindingContext.CONSTRUCTOR, ktConstructor) - val body = createBodyGenerator(constructorDescriptor).generateSecondaryConstructorBody(ktConstructor) - return IrFunctionImpl(ktConstructor.startOffset, ktConstructor.endOffset, IrDeclarationOrigin.DEFINED, - constructorDescriptor, body) + val irConstructor = IrConstructorImpl(ktConstructor.startOffset, ktConstructor.endOffset, IrDeclarationOrigin.DEFINED, constructorDescriptor) + val bodyGenerator = createBodyGenerator(constructorDescriptor) + bodyGenerator.generateDefaultParameters(ktConstructor, irConstructor) + irConstructor.body = bodyGenerator.generateSecondaryConstructorBody(ktConstructor) + return irConstructor } - private fun generateSecondaryConstructorWithNestedInitializers(ktConstructor: KtSecondaryConstructor): IrFunction { + private fun generateSecondaryConstructorWithNestedInitializers(ktConstructor: KtSecondaryConstructor): IrGeneralFunction { val constructorDescriptor = getOrFail(BindingContext.CONSTRUCTOR, ktConstructor) - val body = createBodyGenerator(constructorDescriptor).generateSecondaryConstructorBodyWithNestedInitializers(ktConstructor) - return IrFunctionImpl(ktConstructor.startOffset, ktConstructor.endOffset, IrDeclarationOrigin.DEFINED, - constructorDescriptor, body) + val irConstructor = IrConstructorImpl(ktConstructor.startOffset, ktConstructor.endOffset, IrDeclarationOrigin.DEFINED, constructorDescriptor) + val bodyGenerator = createBodyGenerator(constructorDescriptor) + bodyGenerator.generateDefaultParameters(ktConstructor, irConstructor) + irConstructor.body = createBodyGenerator(constructorDescriptor).generateSecondaryConstructorBodyWithNestedInitializers(ktConstructor) + return irConstructor } fun generatePropertyDeclaration(ktProperty: KtProperty): IrProperty { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt index 7985744f9cf..c1635929ccc 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LocalFunctionGenerator.kt @@ -18,7 +18,7 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin -import org.jetbrains.kotlin.ir.declarations.IrFunction +import org.jetbrains.kotlin.ir.declarations.IrGeneralFunction import org.jetbrains.kotlin.ir.declarations.IrFunctionImpl import org.jetbrains.kotlin.ir.expressions.IrBlockImpl import org.jetbrains.kotlin.ir.expressions.IrCallableReferenceImpl @@ -62,7 +62,7 @@ class LocalFunctionGenerator(statementGenerator: StatementGenerator) : Statement irBlock } - private fun generateFunctionDeclaration(ktFun: KtNamedFunction): IrFunction { + private fun generateFunctionDeclaration(ktFun: KtNamedFunction): IrGeneralFunction { val funDescriptor = getOrFail(BindingContext.FUNCTION, ktFun) val irFun = IrFunctionImpl(ktFun.startOffset, ktFun.endOffset, IrDeclarationOrigin.DEFINED, funDescriptor) irFun.body = BodyGenerator(funDescriptor, statementGenerator.context).generateFunctionBody(ktFun.bodyExpression!!) 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 0eff00257a1..5d38943a468 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 @@ -22,7 +22,7 @@ const val ARGUMENT0_SLOT = 0 const val ARGUMENT1_SLOT = 1 const val DISPATCH_RECEIVER_SLOT = -1 const val EXTENSION_RECEIVER_SLOT = -2 -const val FUNCTION_BODY_SLOT = 0 +const val FUNCTION_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/IrFunction.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrGeneralFunction.kt similarity index 66% rename from compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFunction.kt rename to compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrGeneralFunction.kt index 7f9df31e052..08468c4710a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrFunction.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrGeneralFunction.kt @@ -17,11 +17,14 @@ package org.jetbrains.kotlin.ir.declarations import org.jetbrains.kotlin.descriptors.FunctionDescriptor +import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.expressions.IrBody +import org.jetbrains.kotlin.ir.expressions.IrExpressionBody import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import java.util.* -interface IrFunction : IrDeclaration { +interface IrGeneralFunction : IrDeclaration { override val descriptor: FunctionDescriptor val body: IrBody? @@ -29,11 +32,16 @@ interface IrFunction : IrDeclaration { get() = IrDeclarationKind.FUNCTION } -abstract class IrFunctionBase( +interface IrFunction : IrGeneralFunction { + fun putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) + fun getDefault(parameter: ValueParameterDescriptor): IrExpressionBody? +} + +abstract class IrGeneralFunctionBase( startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin -) : IrDeclarationBase(startOffset, endOffset, origin), IrFunction { +) : IrDeclarationBase(startOffset, endOffset, origin), IrGeneralFunction { constructor( startOffset: Int, endOffset: Int, @@ -69,6 +77,29 @@ abstract class IrFunctionBase( } } +abstract class IrFunctionBase( + startOffset: Int, + endOffset: Int, + origin: IrDeclarationOrigin +) : IrGeneralFunctionBase(startOffset, endOffset, origin), IrFunction { + private val defaults = LinkedHashMap() + + override fun getDefault(parameter: ValueParameterDescriptor): IrExpressionBody? = + defaults[parameter] + + override fun putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) { + expressionBody.assertDetached() + defaults[parameter]?.detach() + defaults[parameter] = expressionBody + expressionBody.setTreeLocation(this, parameter.index) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + defaults.values.forEach { it.accept(visitor, data) } + body?.accept(visitor, data) + } +} + class IrFunctionImpl( startOffset: Int, endOffset: Int, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrPropertyAccessor.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrPropertyAccessor.kt index b39f3b474f2..09b4f1c0e2a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrPropertyAccessor.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrPropertyAccessor.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.descriptors.PropertySetterDescriptor import org.jetbrains.kotlin.ir.expressions.IrBody import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -interface IrPropertyAccessor : IrFunction { +interface IrPropertyAccessor : IrGeneralFunction { override val descriptor: PropertyAccessorDescriptor } @@ -45,7 +45,7 @@ abstract class IrPropertyAccessorBase( endOffset: Int, origin: IrDeclarationOrigin, body: IrBody -) : IrFunctionBase(startOffset, endOffset, origin, body), IrPropertyAccessor +) : IrGeneralFunctionBase(startOffset, endOffset, origin, body), IrPropertyAccessor class IrPropertyGetterImpl( startOffset: Int, 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 d02966e1bf5..c990a5b1968 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 @@ -18,9 +18,7 @@ package org.jetbrains.kotlin.ir.util import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.SourceLocationManager -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.declarations.IrEnumEntry -import org.jetbrains.kotlin.ir.declarations.IrFile +import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.utils.Printer @@ -45,6 +43,23 @@ class DumpIrTreeVisitor(out: Appendable): IrElementVisitor { element.dumpLabeledSubTree(data) } + override fun visitFunction(declaration: IrFunction, data: String) { + visitFunctionWithParameters(declaration, data) + } + + override fun visitConstructor(declaration: IrConstructor, data: String) { + visitFunctionWithParameters(declaration, data) + } + + private fun visitFunctionWithParameters(declaration: IrFunction, data: String) { + declaration.dumpLabeledElementWith(data) { + declaration.descriptor.valueParameters.forEach { valueParameter -> + declaration.getDefault(valueParameter)?.accept(this, valueParameter.name.asString()) + } + declaration.body?.accept(this, "") + } + } + override fun visitClass(declaration: IrClass, data: String) { declaration.dumpLabeledElementWith(data) { declaration.nestedInitializers?.accept(this, "nestedInitializers") 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 51e013a7a01..fb07b24ab2e 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 @@ -42,6 +42,9 @@ class RenderIrElementVisitor : IrElementVisitor { override fun visitFunction(declaration: IrFunction, data: Nothing?): String = "FUN ${declaration.descriptor.render()}" + override fun visitConstructor(declaration: IrConstructor, data: Nothing?): String = + "CONSTRUCTOR ${declaration.descriptor.render()}" + override fun visitProperty(declaration: IrProperty, data: Nothing?): String = "PROPERTY ${declaration.descriptor.render()}" 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 9eb5e4cf273..f175cdd742c 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 @@ -28,10 +28,11 @@ interface IrElementVisitor { fun visitDeclaration(declaration: IrDeclaration, data: D): R = visitElement(declaration, data) fun visitClass(declaration: IrClass, data: D): R = visitDeclaration(declaration, data) fun visitTypeAlias(declaration: IrTypeAlias, data: D): R = visitDeclaration(declaration, data) - fun visitFunction(declaration: IrFunction, data: D): R = visitDeclaration(declaration, data) - fun visitPropertyGetter(declaration: IrPropertyGetter, data: D): R = visitFunction(declaration, data) - fun visitPropertySetter(declaration: IrPropertySetter, data: D): R = visitFunction(declaration, data) - fun visitConstructor(declaration: IrConstructor, data: D): R = visitFunction(declaration, data) + fun visitGeneralFunction(declaration: IrGeneralFunction, data: D) = visitDeclaration(declaration, data) + fun visitFunction(declaration: IrFunction, data: D): R = visitGeneralFunction(declaration, data) + fun visitPropertyGetter(declaration: IrPropertyGetter, data: D): R = visitGeneralFunction(declaration, data) + fun visitPropertySetter(declaration: IrPropertySetter, data: D): R = visitGeneralFunction(declaration, data) + fun visitConstructor(declaration: IrConstructor, data: D): R = visitGeneralFunction(declaration, data) fun visitProperty(declaration: IrProperty, data: D): R = visitDeclaration(declaration, data) fun visitSimpleProperty(declaration: IrSimpleProperty, data: D): R = visitProperty(declaration, data) fun visitDelegatedProperty(declaration: IrDelegatedProperty, data: D): R = visitProperty(declaration, data) diff --git a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt index b9de9810e09..30d4fc714ff 100644 --- a/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt +++ b/compiler/testData/ir/irText/classes/argumentReorderingInDelegatingConstructorCall.txt @@ -1,6 +1,6 @@ FILE /argumentReorderingInDelegatingConstructorCall.kt CLASS CLASS Base - FUN public constructor Base(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + CONSTRUCTOR public constructor Base(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -13,7 +13,7 @@ FILE /argumentReorderingInDelegatingConstructorCall.kt EXPRESSION_BODY GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER CLASS CLASS Test1 - FUN public constructor Test1(/*0*/ xx: kotlin.Int, /*1*/ yy: kotlin.Int) + CONSTRUCTOR public constructor Test1(/*0*/ xx: kotlin.Int, /*1*/ yy: kotlin.Int) BLOCK_BODY BLOCK type=Base operator=ARGUMENTS_REORDERING_FOR_CALL VAR val tmp0_y: kotlin.Int @@ -25,7 +25,7 @@ FILE /argumentReorderingInDelegatingConstructorCall.kt y: GET_VAR tmp0_y type=kotlin.Int operator=null CLASS CLASS Test2 nestedInitializers: BLOCK_BODY - FUN public constructor Test2(/*0*/ xx: kotlin.Int, /*1*/ yy: kotlin.Int) + CONSTRUCTOR public constructor Test2(/*0*/ xx: kotlin.Int, /*1*/ yy: kotlin.Int) BLOCK_BODY BLOCK type=Base operator=ARGUMENTS_REORDERING_FOR_CALL VAR val tmp0_y: kotlin.Int @@ -37,7 +37,7 @@ FILE /argumentReorderingInDelegatingConstructorCall.kt 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 - FUN public constructor Test2(/*0*/ xxx: kotlin.Int, /*1*/ yyy: kotlin.Int, /*2*/ a: kotlin.Any) + 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 VAR val tmp0_yy: kotlin.Int diff --git a/compiler/testData/ir/irText/classes/classMembers.txt b/compiler/testData/ir/irText/classes/classMembers.txt index 6d648bbb084..53384adcb97 100644 --- a/compiler/testData/ir/irText/classes/classMembers.txt +++ b/compiler/testData/ir/irText/classes/classMembers.txt @@ -1,6 +1,8 @@ FILE /classMembers.kt CLASS CLASS C - FUN public constructor C(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int, /*2*/ z: kotlin.Int = ...) + CONSTRUCTOR public constructor C(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int, /*2*/ z: kotlin.Int = ...) + z: EXPRESSION_BODY + CONST Int type=kotlin.Int value='1' BLOCK_BODY SET_BACKING_FIELD y type=kotlin.Unit operator=null GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -14,7 +16,7 @@ FILE /classMembers.kt PROPERTY public final var z: kotlin.Int EXPRESSION_BODY GET_VAR z type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN public constructor C() + CONSTRUCTOR public constructor C() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL C x: CONST Int type=kotlin.Int value='0' @@ -48,7 +50,7 @@ FILE /classMembers.kt CALL .println type=kotlin.Unit operator=null message: CONST String type=kotlin.String value='2' CLASS CLASS NestedClass - FUN public constructor NestedClass() + CONSTRUCTOR public constructor NestedClass() BLOCK_BODY FUN public final fun function(): kotlin.Unit BLOCK_BODY @@ -66,5 +68,5 @@ FILE /classMembers.kt CALL .foo type=kotlin.Unit operator=null $this: THIS public interface NestedInterface type=C.NestedInterface CLASS OBJECT Companion - FUN private constructor Companion() + CONSTRUCTOR private constructor Companion() BLOCK_BODY diff --git a/compiler/testData/ir/irText/classes/classes.txt b/compiler/testData/ir/irText/classes/classes.txt index 5abaa04647a..a75804b1f60 100644 --- a/compiler/testData/ir/irText/classes/classes.txt +++ b/compiler/testData/ir/irText/classes/classes.txt @@ -1,16 +1,16 @@ FILE /classes.kt CLASS CLASS TestClass - FUN public constructor TestClass() + CONSTRUCTOR public constructor TestClass() BLOCK_BODY CLASS INTERFACE TestInterface CLASS OBJECT TestObject - FUN private constructor TestObject() + CONSTRUCTOR private constructor TestObject() BLOCK_BODY CLASS ANNOTATION_CLASS TestAnnotationClass - FUN public constructor TestAnnotationClass() + CONSTRUCTOR public constructor TestAnnotationClass() BLOCK_BODY CLASS ENUM_CLASS TestEnumClass - FUN private constructor TestEnumClass() + CONSTRUCTOR private constructor TestEnumClass() BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super FUN public final /*synthesized*/ fun values(): kotlin.Array diff --git a/compiler/testData/ir/irText/classes/companionObject.txt b/compiler/testData/ir/irText/classes/companionObject.txt index 1ac08d27a0d..37fe1c9419f 100644 --- a/compiler/testData/ir/irText/classes/companionObject.txt +++ b/compiler/testData/ir/irText/classes/companionObject.txt @@ -1,13 +1,13 @@ FILE /companionObject.kt CLASS CLASS Test1 - FUN public constructor Test1() + CONSTRUCTOR public constructor Test1() BLOCK_BODY CLASS OBJECT Companion - FUN private constructor Companion() + CONSTRUCTOR private constructor Companion() BLOCK_BODY CLASS CLASS Test2 - FUN public constructor Test2() + CONSTRUCTOR public constructor Test2() BLOCK_BODY CLASS OBJECT Named - FUN private constructor Named() + CONSTRUCTOR private constructor Named() BLOCK_BODY diff --git a/compiler/testData/ir/irText/classes/dataClasses.txt b/compiler/testData/ir/irText/classes/dataClasses.txt index b93e63123c3..b71d7b67b6b 100644 --- a/compiler/testData/ir/irText/classes/dataClasses.txt +++ b/compiler/testData/ir/irText/classes/dataClasses.txt @@ -1,6 +1,6 @@ FILE /dataClasses.kt CLASS CLASS Test1 - FUN public constructor Test1(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String, /*2*/ z: kotlin.Any) + CONSTRUCTOR public constructor Test1(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String, /*2*/ z: kotlin.Any) BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null 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 6d42b5e7112..7009e9a026f 100644 --- a/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.txt +++ b/compiler/testData/ir/irText/classes/delegatingConstructorCallsInSecondaryConstructors.txt @@ -1,17 +1,17 @@ FILE /delegatingConstructorCallsInSecondaryConstructors.kt CLASS CLASS Base - FUN public constructor Base() + CONSTRUCTOR public constructor Base() BLOCK_BODY CLASS CLASS Test nestedInitializers: BLOCK_BODY - FUN public constructor Test() + CONSTRUCTOR public constructor Test() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Base NESTED_INITIALIZERS_CALL classDescriptor=Test - FUN public constructor Test(/*0*/ xx: kotlin.Int) + CONSTRUCTOR public constructor Test(/*0*/ xx: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Base NESTED_INITIALIZERS_CALL classDescriptor=Test - FUN public constructor Test(/*0*/ xx: kotlin.Short) + 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 2e01a69af6d..5b473b75407 100644 --- a/compiler/testData/ir/irText/classes/enum.txt +++ b/compiler/testData/ir/irText/classes/enum.txt @@ -1,6 +1,6 @@ FILE /enum.kt CLASS ENUM_CLASS TestEnum1 - FUN private constructor TestEnum1() + CONSTRUCTOR private constructor TestEnum1() BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super ENUM_ENTRY enum entry TEST1 @@ -12,7 +12,7 @@ FILE /enum.kt FUN public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): TestEnum1 SYNTHETIC_BODY kind=ENUM_VALUEOF CLASS ENUM_CLASS TestEnum2 - FUN private constructor TestEnum2(/*0*/ x: kotlin.Int) + CONSTRUCTOR private constructor TestEnum2(/*0*/ x: kotlin.Int) BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super SET_BACKING_FIELD x type=kotlin.Unit operator=null @@ -34,13 +34,13 @@ FILE /enum.kt FUN public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): TestEnum2 SYNTHETIC_BODY kind=ENUM_VALUEOF CLASS ENUM_CLASS TestEnum3 - FUN private constructor TestEnum3() + CONSTRUCTOR private constructor TestEnum3() BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super ENUM_ENTRY enum entry TEST init: ENUM_CONSTRUCTOR_CALL TEST TEST class: CLASS ENUM_ENTRY TEST - FUN private constructor TEST() + CONSTRUCTOR private constructor TEST() BLOCK_BODY ENUM_CONSTRUCTOR_CALL TestEnum3 super FUN public open override /*1*/ fun foo(): kotlin.Unit @@ -53,7 +53,7 @@ FILE /enum.kt FUN public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): TestEnum3 SYNTHETIC_BODY kind=ENUM_VALUEOF CLASS ENUM_CLASS TestEnum4 - FUN private constructor TestEnum4(/*0*/ x: kotlin.Int) + CONSTRUCTOR private constructor TestEnum4(/*0*/ x: kotlin.Int) BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super SET_BACKING_FIELD x type=kotlin.Unit operator=null @@ -64,7 +64,7 @@ FILE /enum.kt ENUM_ENTRY enum entry TEST1 init: ENUM_CONSTRUCTOR_CALL TEST1 TEST1 class: CLASS ENUM_ENTRY TEST1 - FUN private constructor TEST1() + CONSTRUCTOR private constructor TEST1() BLOCK_BODY ENUM_CONSTRUCTOR_CALL TestEnum4 super x: CONST Int type=kotlin.Int value='1' @@ -75,7 +75,7 @@ FILE /enum.kt ENUM_ENTRY enum entry TEST2 init: ENUM_CONSTRUCTOR_CALL TEST2 TEST2 class: CLASS ENUM_ENTRY TEST2 - FUN private constructor TEST2() + CONSTRUCTOR private constructor TEST2() BLOCK_BODY ENUM_CONSTRUCTOR_CALL TestEnum4 super x: CONST Int type=kotlin.Int value='2' diff --git a/compiler/testData/ir/irText/classes/initVal.txt b/compiler/testData/ir/irText/classes/initVal.txt index 9f5dd2f7f7c..70d3b87cf65 100644 --- a/compiler/testData/ir/irText/classes/initVal.txt +++ b/compiler/testData/ir/irText/classes/initVal.txt @@ -1,6 +1,6 @@ FILE /initVal.kt CLASS CLASS TestInitValFromParameter - FUN public constructor TestInitValFromParameter(/*0*/ x: kotlin.Int) + CONSTRUCTOR public constructor TestInitValFromParameter(/*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 @@ -8,7 +8,7 @@ FILE /initVal.kt EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER CLASS CLASS TestInitValInClass - FUN public constructor TestInitValInClass() + CONSTRUCTOR public constructor TestInitValInClass() BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null CONST Int type=kotlin.Int value='0' @@ -16,7 +16,7 @@ FILE /initVal.kt EXPRESSION_BODY CONST Int type=kotlin.Int value='0' CLASS CLASS TestInitValInInitBlock - FUN public constructor TestInitValInInitBlock() + CONSTRUCTOR public constructor TestInitValInInitBlock() BLOCK_BODY BLOCK type=kotlin.Unit operator=null SET_BACKING_FIELD x type=kotlin.Unit operator=null diff --git a/compiler/testData/ir/irText/classes/initVar.txt b/compiler/testData/ir/irText/classes/initVar.txt index 47a8378a843..249ba149164 100644 --- a/compiler/testData/ir/irText/classes/initVar.txt +++ b/compiler/testData/ir/irText/classes/initVar.txt @@ -1,6 +1,6 @@ FILE /initVar.kt CLASS CLASS TestInitVarFromParameter - FUN public constructor TestInitVarFromParameter(/*0*/ x: kotlin.Int) + CONSTRUCTOR public constructor TestInitVarFromParameter(/*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 @@ -8,7 +8,7 @@ FILE /initVar.kt EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER CLASS CLASS TestInitVarInClass - FUN public constructor TestInitVarInClass() + CONSTRUCTOR public constructor TestInitVarInClass() BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null CONST Int type=kotlin.Int value='0' @@ -16,7 +16,7 @@ FILE /initVar.kt EXPRESSION_BODY CONST Int type=kotlin.Int value='0' CLASS CLASS TestInitVarInInitBlock - FUN public constructor TestInitVarInInitBlock() + CONSTRUCTOR public constructor TestInitVarInInitBlock() BLOCK_BODY BLOCK type=kotlin.Unit operator=null CALL . type=kotlin.Unit operator=EQ @@ -24,7 +24,7 @@ FILE /initVar.kt : CONST Int type=kotlin.Int value='0' PROPERTY public final var x: kotlin.Int CLASS CLASS TestInitVarWithCustomSetter - FUN public constructor TestInitVarWithCustomSetter() + CONSTRUCTOR public constructor TestInitVarWithCustomSetter() BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null CONST Int type=kotlin.Int value='0' @@ -46,7 +46,7 @@ FILE /initVar.kt BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=EQ GET_VAR value type=kotlin.Int operator=null - FUN public constructor TestInitVarWithCustomSetterWithExplicitCtor() + CONSTRUCTOR public constructor TestInitVarWithCustomSetterWithExplicitCtor() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Any NESTED_INITIALIZERS_CALL classDescriptor=TestInitVarWithCustomSetterWithExplicitCtor @@ -57,7 +57,7 @@ FILE /initVar.kt BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=EQ GET_VAR value type=kotlin.Int operator=null - FUN public constructor TestInitVarWithCustomSetterInCtor() + CONSTRUCTOR public constructor TestInitVarWithCustomSetterInCtor() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Any NESTED_INITIALIZERS_CALL classDescriptor=TestInitVarWithCustomSetterInCtor diff --git a/compiler/testData/ir/irText/classes/localClasses.txt b/compiler/testData/ir/irText/classes/localClasses.txt index f5aefc751e9..b61d75af82d 100644 --- a/compiler/testData/ir/irText/classes/localClasses.txt +++ b/compiler/testData/ir/irText/classes/localClasses.txt @@ -2,7 +2,7 @@ FILE /localClasses.kt FUN public fun outer(): kotlin.Unit BLOCK_BODY CLASS CLASS LocalClass - FUN public constructor LocalClass() + CONSTRUCTOR public constructor LocalClass() BLOCK_BODY FUN public final fun foo(): kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt b/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt index 3e70bb50a11..618359f561a 100644 --- a/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt +++ b/compiler/testData/ir/irText/classes/objectLiteralExpressions.txt @@ -5,14 +5,14 @@ FILE /objectLiteralExpressions.kt EXPRESSION_BODY BLOCK type=test1. operator=OBJECT_LITERAL CLASS CLASS - FUN public constructor () + CONSTRUCTOR public constructor () BLOCK_BODY CALL . type=test1. operator=OBJECT_LITERAL PROPERTY public val test2: IFoo EXPRESSION_BODY BLOCK type=test2. operator=OBJECT_LITERAL CLASS CLASS - FUN public constructor () + CONSTRUCTOR public constructor () BLOCK_BODY FUN public open override /*1*/ fun foo(): kotlin.Unit BLOCK_BODY @@ -20,17 +20,17 @@ FILE /objectLiteralExpressions.kt message: CONST String type=kotlin.String value='foo' CALL . type=test2. operator=OBJECT_LITERAL CLASS CLASS Outer - FUN public constructor Outer() + CONSTRUCTOR public constructor Outer() BLOCK_BODY CLASS CLASS Inner - FUN public constructor Inner() + CONSTRUCTOR public constructor Inner() BLOCK_BODY FUN public final fun test3(): Outer.Inner BLOCK_BODY RETURN type=kotlin.Nothing from=test3 BLOCK type=Outer.test3. operator=OBJECT_LITERAL CLASS CLASS - FUN public constructor () + CONSTRUCTOR public constructor () BLOCK_BODY CALL . type=Outer.Inner operator=SUPER_CONSTRUCTOR_CALL $this: THIS public final class Outer type=Outer @@ -44,7 +44,7 @@ FILE /objectLiteralExpressions.kt RETURN type=kotlin.Nothing from=test4 BLOCK type=test4. operator=OBJECT_LITERAL CLASS CLASS - FUN public constructor () + CONSTRUCTOR public constructor () BLOCK_BODY CALL . type=Outer.Inner operator=SUPER_CONSTRUCTOR_CALL $this: $RECEIVER of: test4 type=Outer diff --git a/compiler/testData/ir/irText/classes/primaryConstructor.txt b/compiler/testData/ir/irText/classes/primaryConstructor.txt index c0300f29818..04e85bc6d68 100644 --- a/compiler/testData/ir/irText/classes/primaryConstructor.txt +++ b/compiler/testData/ir/irText/classes/primaryConstructor.txt @@ -1,6 +1,6 @@ FILE /primaryConstructor.kt CLASS CLASS Test1 - FUN public constructor Test1(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + CONSTRUCTOR public constructor Test1(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null GET_VAR x type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -13,7 +13,7 @@ FILE /primaryConstructor.kt EXPRESSION_BODY GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER CLASS CLASS Test2 - FUN public constructor Test2(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + CONSTRUCTOR public constructor Test2(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) BLOCK_BODY SET_BACKING_FIELD y type=kotlin.Unit operator=null GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER @@ -26,7 +26,7 @@ FILE /primaryConstructor.kt EXPRESSION_BODY GET_VAR x type=kotlin.Int operator=null CLASS CLASS Test3 - FUN public constructor Test3(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + CONSTRUCTOR public constructor Test3(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) BLOCK_BODY SET_BACKING_FIELD y type=kotlin.Unit operator=null GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER diff --git a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt index e2cc396f00d..452bb8f0501 100644 --- a/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt +++ b/compiler/testData/ir/irText/classes/primaryConstructorWithSuperConstructorCall.txt @@ -1,17 +1,17 @@ FILE /primaryConstructorWithSuperConstructorCall.kt CLASS CLASS Base - FUN public constructor Base() + CONSTRUCTOR public constructor Base() BLOCK_BODY CLASS CLASS TestImplicitPrimaryConstructor - FUN public constructor TestImplicitPrimaryConstructor() + CONSTRUCTOR public constructor TestImplicitPrimaryConstructor() BLOCK_BODY CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL CLASS CLASS TestExplicitPrimaryConstructor - FUN public constructor TestExplicitPrimaryConstructor() + CONSTRUCTOR public constructor TestExplicitPrimaryConstructor() BLOCK_BODY CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL CLASS CLASS TestWithDelegatingConstructor - FUN public constructor TestWithDelegatingConstructor(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) + CONSTRUCTOR public constructor TestWithDelegatingConstructor(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int) BLOCK_BODY CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL SET_BACKING_FIELD x type=kotlin.Unit operator=null @@ -24,7 +24,7 @@ FILE /primaryConstructorWithSuperConstructorCall.kt PROPERTY public final val y: kotlin.Int EXPRESSION_BODY GET_VAR y type=kotlin.Int operator=INITIALIZE_PROPERTY_FROM_PARAMETER - FUN public constructor TestWithDelegatingConstructor(/*0*/ x: kotlin.Int) + CONSTRUCTOR public constructor TestWithDelegatingConstructor(/*0*/ x: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL TestWithDelegatingConstructor x: GET_VAR x type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.txt b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.txt index 0681b83fec5..aba929fdafe 100644 --- a/compiler/testData/ir/irText/classes/qualifiedSuperCalls.txt +++ b/compiler/testData/ir/irText/classes/qualifiedSuperCalls.txt @@ -16,7 +16,7 @@ FILE /qualifiedSuperCalls.kt RETURN type=kotlin.Nothing from= CONST Int type=kotlin.Int value='2' CLASS CLASS CBoth - FUN public constructor CBoth() + CONSTRUCTOR public constructor CBoth() BLOCK_BODY FUN public open override /*2*/ fun foo(): kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.txt b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.txt index 10e81501f4f..688a8f63181 100644 --- a/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.txt +++ b/compiler/testData/ir/irText/classes/secondaryConstructorWithInitializersFromClassBody.txt @@ -1,6 +1,6 @@ FILE /secondaryConstructorWithInitializersFromClassBody.kt CLASS CLASS Base - FUN public constructor Base() + CONSTRUCTOR public constructor Base() BLOCK_BODY CLASS CLASS TestProperty nestedInitializers: BLOCK_BODY @@ -9,7 +9,7 @@ FILE /secondaryConstructorWithInitializersFromClassBody.kt PROPERTY public final val x: kotlin.Int = 0 EXPRESSION_BODY CONST Int type=kotlin.Int value='0' - FUN public constructor TestProperty() + CONSTRUCTOR public constructor TestProperty() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Base NESTED_INITIALIZERS_CALL classDescriptor=TestProperty @@ -19,7 +19,7 @@ FILE /secondaryConstructorWithInitializersFromClassBody.kt SET_BACKING_FIELD x type=kotlin.Unit operator=null CONST Int type=kotlin.Int value='0' PROPERTY public final val x: kotlin.Int - FUN public constructor TestInitBlock() + CONSTRUCTOR public constructor TestInitBlock() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Base NESTED_INITIALIZERS_CALL classDescriptor=TestInitBlock diff --git a/compiler/testData/ir/irText/classes/secondaryConstructors.txt b/compiler/testData/ir/irText/classes/secondaryConstructors.txt index deb367a4c54..d1cc6373d93 100644 --- a/compiler/testData/ir/irText/classes/secondaryConstructors.txt +++ b/compiler/testData/ir/irText/classes/secondaryConstructors.txt @@ -1,11 +1,11 @@ FILE /secondaryConstructors.kt CLASS CLASS C nestedInitializers: BLOCK_BODY - FUN public constructor C() + CONSTRUCTOR public constructor C() BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL C x: CONST Int type=kotlin.Int value='0' - FUN public constructor C(/*0*/ x: kotlin.Int) + CONSTRUCTOR public constructor C(/*0*/ x: kotlin.Int) BLOCK_BODY DELEGATING_CONSTRUCTOR_CALL Any NESTED_INITIALIZERS_CALL classDescriptor=C diff --git a/compiler/testData/ir/irText/classes/superCalls.txt b/compiler/testData/ir/irText/classes/superCalls.txt index c5019ce3cc2..14cdefc436e 100644 --- a/compiler/testData/ir/irText/classes/superCalls.txt +++ b/compiler/testData/ir/irText/classes/superCalls.txt @@ -1,6 +1,6 @@ FILE /superCalls.kt CLASS CLASS Base - FUN public constructor Base() + CONSTRUCTOR public constructor Base() BLOCK_BODY SET_BACKING_FIELD bar type=kotlin.Unit operator=null CONST String type=kotlin.String value='' @@ -10,7 +10,7 @@ FILE /superCalls.kt EXPRESSION_BODY CONST String type=kotlin.String value='' CLASS CLASS Derived - FUN public constructor Derived() + CONSTRUCTOR public constructor Derived() BLOCK_BODY CALL . type=Base operator=SUPER_CONSTRUCTOR_CALL FUN public open override /*1*/ fun foo(): kotlin.Unit diff --git a/compiler/testData/ir/irText/defaultArguments.kt b/compiler/testData/ir/irText/defaultArguments.kt new file mode 100644 index 00000000000..052c38a6276 --- /dev/null +++ b/compiler/testData/ir/irText/defaultArguments.kt @@ -0,0 +1 @@ +fun test1(x: Int, y: Int = 0, z: String = "abc") {} diff --git a/compiler/testData/ir/irText/defaultArguments.txt b/compiler/testData/ir/irText/defaultArguments.txt new file mode 100644 index 00000000000..4b6a48422ce --- /dev/null +++ b/compiler/testData/ir/irText/defaultArguments.txt @@ -0,0 +1,7 @@ +FILE /defaultArguments.kt + FUN public fun test1(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int = ..., /*2*/ z: kotlin.String = ...): kotlin.Unit + y: EXPRESSION_BODY + CONST Int type=kotlin.Int value='0' + z: EXPRESSION_BODY + CONST String type=kotlin.String value='abc' + BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt index 9ca8fc43135..ee96143dff4 100644 --- a/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt +++ b/compiler/testData/ir/irText/expressions/arrayAugmentedAssignment1.txt @@ -12,7 +12,7 @@ FILE /arrayAugmentedAssignment1.kt RETURN type=kotlin.Nothing from=bar CONST Int type=kotlin.Int value='42' CLASS CLASS C - FUN public constructor C(/*0*/ x: kotlin.IntArray) + CONSTRUCTOR public constructor C(/*0*/ x: kotlin.IntArray) BLOCK_BODY SET_BACKING_FIELD x type=kotlin.Unit operator=null 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 a8a2a26cd78..541ef63633b 100644 --- a/compiler/testData/ir/irText/expressions/assignments.txt +++ b/compiler/testData/ir/irText/expressions/assignments.txt @@ -1,6 +1,6 @@ FILE /assignments.kt CLASS CLASS Ref - FUN public constructor Ref(/*0*/ x: kotlin.Int) + CONSTRUCTOR public constructor Ref(/*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 diff --git a/compiler/testData/ir/irText/expressions/augmentedAssignment2.txt b/compiler/testData/ir/irText/expressions/augmentedAssignment2.txt index 8953c176239..863e9287e5b 100644 --- a/compiler/testData/ir/irText/expressions/augmentedAssignment2.txt +++ b/compiler/testData/ir/irText/expressions/augmentedAssignment2.txt @@ -1,6 +1,6 @@ FILE /augmentedAssignment2.kt CLASS CLASS A - FUN public constructor A() + CONSTRUCTOR public constructor A() BLOCK_BODY FUN public operator fun A.plusAssign(/*0*/ s: kotlin.String): kotlin.Unit BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt index 1fc2accf9ba..11e1dbf6def 100644 --- a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt +++ b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt @@ -1,6 +1,6 @@ FILE /chainOfSafeCalls.kt CLASS CLASS C - FUN public constructor C() + CONSTRUCTOR public constructor C() BLOCK_BODY FUN public final fun foo(): C BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt index c7c4bf5dc0f..10d3bdcae68 100644 --- a/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt +++ b/compiler/testData/ir/irText/expressions/forWithImplicitReceivers.txt @@ -1,9 +1,9 @@ FILE /forWithImplicitReceivers.kt CLASS OBJECT FiveTimes - FUN private constructor FiveTimes() + CONSTRUCTOR private constructor FiveTimes() BLOCK_BODY CLASS CLASS IntCell - FUN public constructor IntCell(/*0*/ value: kotlin.Int) + 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 diff --git a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt index d9aa362e131..51b8d5135a6 100644 --- a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt +++ b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt @@ -21,7 +21,7 @@ FILE /jvmStaticFieldReference.kt CALL . type=java.io.PrintStream! operator=GET_PROPERTY p0: CONST String type=kotlin.String value='testProp/set' CLASS CLASS TestClass - FUN public constructor TestClass() + CONSTRUCTOR public constructor TestClass() BLOCK_BODY SET_BACKING_FIELD test type=kotlin.Unit operator=null WHEN type=kotlin.Int operator=WHEN diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt index 3762c4bde4a..5836b8ebf6c 100644 --- a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt @@ -1,6 +1,6 @@ FILE /safeCallWithIncrementDecrement.kt CLASS CLASS C - FUN public constructor C() + CONSTRUCTOR public constructor C() BLOCK_BODY PROPERTY public var test.C?.p: kotlin.Int PROPERTY_GETTER public fun test.C?.(): kotlin.Int diff --git a/compiler/testData/ir/irText/expressions/safeCalls.txt b/compiler/testData/ir/irText/expressions/safeCalls.txt index 534f5151159..f8168b930e7 100644 --- a/compiler/testData/ir/irText/expressions/safeCalls.txt +++ b/compiler/testData/ir/irText/expressions/safeCalls.txt @@ -1,6 +1,6 @@ FILE /safeCalls.kt CLASS CLASS Ref - FUN public constructor Ref(/*0*/ value: kotlin.Int) + CONSTRUCTOR public constructor Ref(/*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 diff --git a/compiler/testData/ir/irText/expressions/values.txt b/compiler/testData/ir/irText/expressions/values.txt index cbe792296ce..9496a326946 100644 --- a/compiler/testData/ir/irText/expressions/values.txt +++ b/compiler/testData/ir/irText/expressions/values.txt @@ -1,6 +1,6 @@ FILE /values.kt CLASS ENUM_CLASS Enum - FUN private constructor Enum() + CONSTRUCTOR private constructor Enum() BLOCK_BODY ENUM_CONSTRUCTOR_CALL Enum super ENUM_ENTRY enum entry A @@ -10,16 +10,16 @@ FILE /values.kt FUN public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): Enum SYNTHETIC_BODY kind=ENUM_VALUEOF CLASS OBJECT A - FUN private constructor A() + CONSTRUCTOR private constructor A() BLOCK_BODY PROPERTY public val a: kotlin.Int = 0 EXPRESSION_BODY CONST Int type=kotlin.Int value='0' CLASS CLASS Z - FUN public constructor Z() + CONSTRUCTOR public constructor Z() BLOCK_BODY CLASS OBJECT Companion - FUN private constructor Companion() + CONSTRUCTOR private constructor Companion() BLOCK_BODY FUN public fun test1(): Enum BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/when.txt b/compiler/testData/ir/irText/expressions/when.txt index 951a05cde86..50f15c36e37 100644 --- a/compiler/testData/ir/irText/expressions/when.txt +++ b/compiler/testData/ir/irText/expressions/when.txt @@ -1,6 +1,6 @@ FILE /when.kt CLASS OBJECT A - FUN private constructor A() + CONSTRUCTOR private constructor A() BLOCK_BODY FUN public fun testWithSubject(/*0*/ x: kotlin.Any?): kotlin.String BLOCK_BODY diff --git a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt index 2c88052ccd7..f13c346e2e5 100644 --- a/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt +++ b/compiler/testData/ir/irText/lambdas/multipleImplicitReceivers.txt @@ -1,9 +1,9 @@ FILE /multipleImplicitReceivers.kt CLASS OBJECT A - FUN private constructor A() + CONSTRUCTOR private constructor A() BLOCK_BODY CLASS OBJECT B - FUN private constructor B() + CONSTRUCTOR private constructor B() BLOCK_BODY CLASS INTERFACE IFoo PROPERTY public open val A.foo: B diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 7c299ca3cf0..5abfccac2a0 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -35,6 +35,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irText"), Pattern.compile("^(.+)\\.kt$"), true); } + @TestMetadata("defaultArguments.kt") + public void testDefaultArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/defaultArguments.kt"); + doTest(fileName); + } + @TestMetadata("compiler/testData/ir/irText/classes") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)