From be86739d3ad2d79afa5cdc26645cf7c85b81dcf4 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Thu, 25 Aug 2016 14:19:37 +0300 Subject: [PATCH] IrBlockBody Change block typing contract. --- ...ssionBodyGenerator.kt => BodyGenerator.kt} | 35 +- .../BranchingExpressionGenerator.kt | 7 +- .../psi2ir/generators/CallGeneration.kt | 24 +- .../kotlin/psi2ir/generators/CallGenerator.kt | 2 +- .../psi2ir/generators/DeclarationGenerator.kt | 10 +- .../kotlin/psi2ir/generators/Generator.kt | 30 +- .../generators/LoopExpressionGenerator.kt | 10 +- .../generators/OperatorExpressionGenerator.kt | 6 +- .../psi2ir/generators/StatementGenerator.kt | 24 +- .../ArrayAccessAssignmentReceiver.kt | 2 +- .../psi2ir/intermediate/SafeCallReceiver.kt | 2 +- .../intermediate/SimplePropertyLValue.kt | 2 +- .../transformations/InlineDesugaredBlocks.kt | 5 +- .../transformations/InlineSafeCallChains.kt | 2 +- .../transformations/InsertImplicitCasts.kt | 11 +- .../kotlin/ir/declarations/IrClass.kt | 4 +- .../kotlin/ir/expressions/IrBlock.kt | 2 - .../jetbrains/kotlin/ir/expressions/IrBody.kt | 48 ++- .../kotlin/ir/expressions/IrOperator.kt | 3 +- .../kotlin/ir/util/RenderIrElement.kt | 17 +- .../kotlin/ir/visitors/IrElementVisitor.kt | 4 +- compiler/testData/ir/irText/arrayAccess.txt | 40 +- .../testData/ir/irText/arrayAssignment.txt | 49 ++- .../ir/irText/arrayAugmentedAssignment1.txt | 109 +++--- .../ir/irText/arrayAugmentedAssignment2.txt | 27 +- compiler/testData/ir/irText/assignments.txt | 34 +- .../ir/irText/augmentedAssignment1.txt | 100 +++-- .../ir/irText/augmentedAssignment2.txt | 105 +++-- .../testData/ir/irText/booleanOperators.txt | 58 ++- compiler/testData/ir/irText/boxOk.txt | 11 +- compiler/testData/ir/irText/breakContinue.txt | 117 +++--- .../ir/irText/callWithReorderedArguments.txt | 80 ++-- compiler/testData/ir/irText/calls.txt | 74 ++-- .../testData/ir/irText/chainOfSafeCalls.txt | 35 +- .../ir/irText/conventionComparisons.txt | 70 ++-- .../testData/ir/irText/destructuring1.txt | 27 +- compiler/testData/ir/irText/dotQualified.txt | 34 +- compiler/testData/ir/irText/elvis.txt | 152 ++++---- compiler/testData/ir/irText/equality.txt | 39 +- .../ir/irText/extensionPropertyGetterCall.txt | 24 +- compiler/testData/ir/irText/for.txt | 84 ++-- .../ir/irText/forWithBreakContinue.txt | 186 +++++---- .../ir/irText/forWithImplicitReceivers.txt | 41 +- compiler/testData/ir/irText/identity.txt | 39 +- compiler/testData/ir/irText/ifElseIf.txt | 35 +- .../ir/irText/implicitCastOnPlatformType.txt | 15 +- compiler/testData/ir/irText/in.txt | 50 ++- .../testData/ir/irText/incrementDecrement.txt | 272 +++++++------ compiler/testData/ir/irText/literals.txt | 26 +- .../ir/irText/primitiveComparisons.txt | 362 ++++++++---------- compiler/testData/ir/irText/references.txt | 83 ++-- .../irText/safeCallWithIncrementDecrement.txt | 115 +++--- compiler/testData/ir/irText/safeCalls.txt | 105 +++-- .../testData/ir/irText/simpleOperators.txt | 145 ++++--- .../ir/irText/simpleUnaryOperators.txt | 68 ++-- compiler/testData/ir/irText/smartCasts.txt | 107 +++--- .../ir/irText/smartCastsWithDestructuring.txt | 49 ++- compiler/testData/ir/irText/smoke.kt | 11 +- compiler/testData/ir/irText/smoke.txt | 46 +-- .../testData/ir/irText/stringComparisons.txt | 62 ++- compiler/testData/ir/irText/stringPlus.txt | 51 ++- compiler/testData/ir/irText/throw.txt | 30 +- compiler/testData/ir/irText/tryCatch.kt | 6 - compiler/testData/ir/irText/tryCatch.txt | 54 +-- .../ir/irText/tryCatchWithImplicitCast.kt | 5 + .../ir/irText/tryCatchWithImplicitCast.txt | 14 + compiler/testData/ir/irText/typeOperators.txt | 46 +-- compiler/testData/ir/irText/values.txt | 42 +- .../ir/irText/variableAsFunctionCall.txt | 67 ++-- compiler/testData/ir/irText/when.txt | 133 ++++--- compiler/testData/ir/irText/whileDoWhile.txt | 132 ++++--- .../kotlin/ir/IrTextTestCaseGenerated.java | 6 + 72 files changed, 1882 insertions(+), 2040 deletions(-) rename compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/{ExpressionBodyGenerator.kt => BodyGenerator.kt} (60%) create mode 100644 compiler/testData/ir/irText/tryCatchWithImplicitCast.kt create mode 100644 compiler/testData/ir/irText/tryCatchWithImplicitCast.txt diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ExpressionBodyGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt similarity index 60% rename from compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ExpressionBodyGenerator.kt rename to compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt index 997b4a0f918..6ce68ea56dd 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ExpressionBodyGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt @@ -17,35 +17,37 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.CallableDescriptor -import org.jetbrains.kotlin.ir.expressions.IrBlockImpl -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrLoop -import org.jetbrains.kotlin.ir.expressions.IrReturnImpl +import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.psi.KtBlockExpression import org.jetbrains.kotlin.psi.KtExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset import java.util.* -class ExpressionBodyGenerator(val scopeOwner: CallableDescriptor, override val context: GeneratorContext): GeneratorWithScope { +class BodyGenerator(val scopeOwner: CallableDescriptor, override val context: GeneratorContext): GeneratorWithScope { override val scope = Scope(scopeOwner) private val loopTable = HashMap() - fun generateFunctionBody(ktBody: KtExpression): IrExpression { + fun generateFunctionBody(ktBody: KtExpression): IrBody { resetInternalContext() - val irBodyExpression = createStatementGenerator().generateExpression(ktBody) + val statementGenerator = createStatementGenerator() - val irBodyExpressionAsBlock = - if (ktBody is KtBlockExpression) - irBodyExpression - else IrBlockImpl(ktBody.startOffset, ktBody.endOffset, null, false).apply { - addStatement(IrReturnImpl(ktBody.startOffset, ktBody.endOffset, scopeOwner, irBodyExpression)) - } + val irBlockBody = IrBlockBodyImpl(ktBody.startOffset, ktBody.endOffset) + if (ktBody is KtBlockExpression) { + for (ktStatement in ktBody.statements) { + irBlockBody.addStatement(statementGenerator.generateStatement(ktStatement)) + } + } + else { + val irBodyExpression = statementGenerator.generateExpression(ktBody) + val irReturn = IrReturnImpl(ktBody.startOffset, ktBody.endOffset, scopeOwner, irBodyExpression) + irBlockBody.addStatement(irReturn) + } postprocessFunctionBody() - return irBodyExpressionAsBlock + return irBlockBody } private fun resetInternalContext() { @@ -55,8 +57,9 @@ class ExpressionBodyGenerator(val scopeOwner: CallableDescriptor, override val c private fun postprocessFunctionBody() { } - fun generatePropertyInitializerBody(ktInitializer: KtExpression): IrExpression = - createStatementGenerator().generateExpression(ktInitializer) + fun generatePropertyInitializerBody(ktInitializer: KtExpression): IrBody = + IrExpressionBodyImpl(ktInitializer.startOffset, ktInitializer.endOffset, + createStatementGenerator().generateExpression(ktInitializer)) private fun createStatementGenerator() = StatementGenerator(context, scopeOwner, this, scope) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt index 8124dfaa0aa..0ba31af587d 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.psi2ir.defaultLoad import org.jetbrains.kotlin.psi2ir.deparenthesize -import org.jetbrains.kotlin.psi2ir.generators.getInfixOperator import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.utils.SmartList import java.lang.AssertionError @@ -107,18 +106,18 @@ class BranchingExpressionGenerator(val statementGenerator: StatementGenerator) : private fun generateWhenBody(expression: KtWhenExpression, irSubject: IrVariable?, irWhen: IrWhen): IrExpression { if (irSubject == null) { if (irWhen.branchesCount == 0) - return IrBlockImpl(expression.startOffset, expression.endOffset, null, false, IrOperator.WHEN) + return IrBlockImpl(expression.startOffset, expression.endOffset, context.builtIns.unitType, IrOperator.WHEN) else return irWhen } else { if (irWhen.branchesCount == 0) { - val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, null, false, IrOperator.WHEN) + val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, context.builtIns.unitType, IrOperator.WHEN) irBlock.addStatement(irSubject) return irBlock } else { - val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, irWhen.type, true, IrOperator.WHEN) + val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, irWhen.type, IrOperator.WHEN) irBlock.addStatement(irSubject) irBlock.addStatement(irWhen) return irBlock diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGeneration.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGeneration.kt index d992d84e290..40fe8c6c7ee 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGeneration.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGeneration.kt @@ -68,19 +68,17 @@ fun StatementGenerator.generateCallReceiver( val dispatchReceiverValue = generateReceiverOrNull(ktDefaultElement, dispatchReceiver) val extensionReceiverValue = generateReceiverOrNull(ktDefaultElement, extensionReceiver) - if (!isSafe) { - return SimpleCallReceiver(dispatchReceiverValue, extensionReceiverValue) - } - else if (extensionReceiverValue != null) { - return SafeCallReceiver(this, ktDefaultElement.startOffset, ktDefaultElement.endOffset, - extensionReceiverValue.load(), dispatchReceiverValue) - } - else if (dispatchReceiverValue != null) { - return SafeCallReceiver(this, ktDefaultElement.startOffset, ktDefaultElement.endOffset, - dispatchReceiverValue.load(), null) - } - else { - return throw AssertionError("Safe call should have an explicit receiver: ${ktDefaultElement.text}") + return when { + !isSafe -> + SimpleCallReceiver(dispatchReceiverValue, extensionReceiverValue) + extensionReceiverValue != null -> + SafeCallReceiver(this, ktDefaultElement.startOffset, ktDefaultElement.endOffset, + extensionReceiverValue.load(), dispatchReceiverValue) + dispatchReceiverValue != null -> + SafeCallReceiver(this, ktDefaultElement.startOffset, ktDefaultElement.endOffset, + dispatchReceiverValue.load(), null) + else -> + throw AssertionError("Safe call should have an explicit receiver: ${ktDefaultElement.text}") } } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt index 613418d14c7..5cc999c08e4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt @@ -118,7 +118,7 @@ class CallGenerator( val valueArgumentsInEvaluationOrder = resolvedCall.valueArguments.values val valueParameters = resolvedCall.resultingDescriptor.valueParameters - val irBlock = IrBlockImpl(startOffset, endOffset, resultType, true, IrOperator.SYNTHETIC_BLOCK) + val irBlock = IrBlockImpl(startOffset, endOffset, resultType, IrOperator.ARGUMENTS_REORDERING_FOR_CALL) val valueArgumentsToValueParameters = HashMap() for ((index, valueArgument) in resolvedCall.valueArgumentsByIndex!!.withIndex()) { 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 e1a4e0404ab..33ee5e39b32 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 @@ -25,10 +25,6 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.BindingContext class DeclarationGenerator(override val context: GeneratorContext) : Generator { - fun generateAnnotationEntries(annotationEntries: List) { - // TODO create IrAnnotation's for each KtAnnotationEntry - } - fun generateMemberDeclaration(ktDeclaration: KtDeclaration): IrDeclaration = when (ktDeclaration) { is KtNamedFunction -> @@ -122,10 +118,8 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator { } private fun generateFunctionBody(scopeOwner: CallableDescriptor, ktBody: KtExpression): IrBody = - IrExpressionBodyImpl(ktBody.startOffset, ktBody.endOffset, - ExpressionBodyGenerator(scopeOwner, context).generateFunctionBody(ktBody)) + BodyGenerator(scopeOwner, context).generateFunctionBody(ktBody) private fun generateInitializerBody(scopeOwner: CallableDescriptor, ktBody: KtExpression): IrBody = - IrExpressionBodyImpl(ktBody.startOffset, ktBody.endOffset, - ExpressionBodyGenerator(scopeOwner, context).generatePropertyInitializerBody(ktBody)) + BodyGenerator(scopeOwner, context).generatePropertyInitializerBody(ktBody) } \ No newline at end of file diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt index 3e18dc4ac8f..e3353ad72ff 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/Generator.kt @@ -19,10 +19,12 @@ package org.jetbrains.kotlin.psi2ir.generators import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.ir.expressions.IrDummyExpression -import org.jetbrains.kotlin.psi.* +import org.jetbrains.kotlin.psi.KtBlockExpression +import org.jetbrains.kotlin.psi.KtConstantExpression +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtStringTemplateExpression import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset -import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall @@ -58,9 +60,6 @@ fun Generator.getInferredTypeWithSmartcasts(key: KtExpression): KotlinType? = fun Generator.getInferredTypeWithSmartcastsOrFail(key: KtExpression): KotlinType = getInferredTypeWithSmartcasts(key) ?: throw AssertionError("No type for expression: ${key.text}") -fun Generator.isUsedAsExpression(ktElement: KtElement) = - get(BindingContext.USED_AS_EXPRESSION, ktElement) ?: false - fun Generator.getResolvedCall(key: KtExpression): ResolvedCall? = key.getResolvedCall(context.bindingContext) @@ -70,20 +69,17 @@ fun Generator.getReturnType(key: KtExpression): KotlinType? { return getReturnType(resolvedCall) } - if (key is KtBlockExpression) { - if (!isUsedAsExpression(key)) return null - return getReturnType(key.statements.last()) + return when (key) { + is KtBlockExpression -> + getReturnType(key.statements.last()) + is KtConstantExpression -> + getInferredTypeWithSmartcasts(key) + is KtStringTemplateExpression -> + context.builtIns.stringType + else -> + throw AssertionError("Unexpected expression: $key") } - if (key is KtConstantExpression) { - return getInferredTypeWithSmartcasts(key) - } - - if (key is KtStringTemplateExpression) { - return context.builtIns.stringType - } - - throw AssertionError("Unexpected expression: $key") } fun getReturnType(resolvedCall: ResolvedCall<*>): KotlinType { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LoopExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LoopExpressionGenerator.kt index aeaa8a29ea8..221f660dee1 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LoopExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/LoopExpressionGenerator.kt @@ -38,7 +38,7 @@ class LoopExpressionGenerator(val statementGenerator: StatementGenerator) : Gene generateConditionalLoop(ktDoWhile, IrDoWhileLoopImpl(ktDoWhile.startOffset, ktDoWhile.endOffset, IrOperator.DO_WHILE_LOOP)) private fun generateConditionalLoop(ktLoop: KtWhileExpressionBase, irLoop: IrLoopBase): IrLoop { - statementGenerator.expressionBodyGenerator.putLoop(ktLoop, irLoop) + statementGenerator.bodyGenerator.putLoop(ktLoop, irLoop) irLoop.condition = statementGenerator.generateExpression(ktLoop.condition!!) irLoop.body = statementGenerator.generateExpression(ktLoop.body!!) irLoop.label = getLoopLabel(ktLoop) @@ -89,7 +89,7 @@ class LoopExpressionGenerator(val statementGenerator: StatementGenerator) : Gene } private fun getLoop(ktLoop: KtLoopExpression): IrLoop { - return statementGenerator.expressionBodyGenerator.getLoop(ktLoop) ?: + return statementGenerator.bodyGenerator.getLoop(ktLoop) ?: throw AssertionError("Loop was not visited:\n${ktLoop.text}") } @@ -108,7 +108,7 @@ class LoopExpressionGenerator(val statementGenerator: StatementGenerator) : Gene val callGenerator = CallGenerator(statementGenerator) - val irForBlock = IrBlockImpl(ktFor.startOffset, ktFor.endOffset, context.builtIns.unitType, false, IrOperator.FOR_LOOP) + val irForBlock = IrBlockImpl(ktFor.startOffset, ktFor.endOffset, context.builtIns.unitType, IrOperator.FOR_LOOP) val iteratorCall = statementGenerator.pregenerateCall(iteratorResolvedCall) val irIteratorCall = callGenerator.generateCall(ktLoopRange, iteratorCall, IrOperator.FOR_LOOP_ITERATOR) @@ -118,7 +118,7 @@ class LoopExpressionGenerator(val statementGenerator: StatementGenerator) : Gene val irInnerWhile = IrWhileLoopImpl(ktFor.startOffset, ktFor.endOffset, IrOperator.FOR_LOOP_INNER_WHILE) irInnerWhile.label = getLoopLabel(ktFor) - statementGenerator.expressionBodyGenerator.putLoop(ktFor, irInnerWhile) + statementGenerator.bodyGenerator.putLoop(ktFor, irInnerWhile) irForBlock.addStatement(irInnerWhile) val hasNextCall = statementGenerator.pregenerateCall(hasNextResolvedCall) @@ -126,7 +126,7 @@ class LoopExpressionGenerator(val statementGenerator: StatementGenerator) : Gene val irHasNextCall = callGenerator.generateCall(ktLoopRange, hasNextCall, IrOperator.FOR_LOOP_HAS_NEXT) irInnerWhile.condition = irHasNextCall - val irInnerBody = IrBlockImpl(ktFor.startOffset, ktFor.endOffset, context.builtIns.unitType, false, IrOperator.FOR_LOOP_INNER_WHILE) + val irInnerBody = IrBlockImpl(ktFor.startOffset, ktFor.endOffset, context.builtIns.unitType, IrOperator.FOR_LOOP_INNER_WHILE) irInnerWhile.body = irInnerBody val nextCall = statementGenerator.pregenerateCall(nextResolvedCall) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt index 21a03435d4d..d792d3a7692 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt @@ -117,7 +117,7 @@ class OperatorExpressionGenerator( val irArgument0 = statementGenerator.generateExpression(expression.left!!) val irArgument1 = statementGenerator.generateExpression(expression.right!!) - val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, returnType, true, IrOperator.ELVIS) + val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, returnType, IrOperator.ELVIS) val irArgument0Value = createRematerializableOrTemporary(scope, irArgument0, irBlock, "elvis_lhs") irBlock.addStatement(IrIfThenElseImpl( expression.startOffset, expression.endOffset, returnType, @@ -225,7 +225,7 @@ class OperatorExpressionGenerator( val irAssignmentReceiver = generateAssignmentReceiver(ktBaseExpression, irOperator) return irAssignmentReceiver.assign { irLValue -> - val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, irLValue.type, true, irOperator) + val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, irLValue.type, irOperator) // VAR tmp = [lhs].inc() val opCall = statementGenerator.pregenerateCall(opResolvedCall) @@ -250,7 +250,7 @@ class OperatorExpressionGenerator( val irAssignmentReceiver = generateAssignmentReceiver(ktBaseExpression, irOperator) return irAssignmentReceiver.assign { irLValue -> - val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, irLValue.type, true, irOperator) + val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, irLValue.type, irOperator) // VAR tmp = [lhs] val irTmp = scope.createTemporaryVariable(irLValue.load()) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt index e8ce1038106..6f95e59cffa 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/StatementGenerator.kt @@ -40,14 +40,16 @@ import org.jetbrains.kotlin.resolve.constants.StringValue import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator import org.jetbrains.kotlin.resolve.descriptorUtil.classValueType import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils -import java.lang.AssertionError class StatementGenerator( override val context: GeneratorContext, val scopeOwner: DeclarationDescriptor, - val expressionBodyGenerator: ExpressionBodyGenerator, + val bodyGenerator: BodyGenerator, override val scope: Scope ) : KtVisitor(), GeneratorWithScope { + fun generateStatement(ktElement: KtElement): IrStatement = + ktElement.genStmt() + fun generateExpression(ktExpression: KtExpression): IrExpression = ktExpression.genExpr() @@ -73,7 +75,8 @@ class StatementGenerator( override fun visitDestructuringDeclaration(multiDeclaration: KtDestructuringDeclaration, data: Nothing?): IrStatement { // TODO use some special form that introduces multiple declarations into surrounding scope? - val irBlock = IrBlockImpl(multiDeclaration.startOffset, multiDeclaration.endOffset, null, false, IrOperator.SYNTHETIC_BLOCK) + val irBlock = IrBlockImpl(multiDeclaration.startOffset, multiDeclaration.endOffset, + context.builtIns.unitType, IrOperator.DESTRUCTURING_DECLARATION) val ktInitializer = multiDeclaration.initializer!! val containerValue = createRematerializableOrTemporary(scope, ktInitializer.genExpr(), irBlock, "container") @@ -100,11 +103,16 @@ class StatementGenerator( } override fun visitBlockExpression(expression: KtBlockExpression, data: Nothing?): IrStatement { - val isBlockBody = expression.parent is KtNamedFunction - val hasResult = if (isBlockBody) false else isUsedAsExpression(expression) - val returnType = if (isBlockBody || !hasResult) null else getReturnType(expression) - val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, returnType, hasResult) - expression.statements.forEach { irBlock.addStatement(it.genStmt()) } + val isBlockBody = expression.parent is KtDeclarationWithBody && expression.parent !is KtFunctionLiteral + if (isBlockBody) throw AssertionError("Use IrBlockBody and corresponding body generator to generate blocks as function bodies") + + val returnType = getInferredTypeWithSmartcasts(expression) ?: context.builtIns.unitType + val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, returnType) + + expression.statements.forEach { + irBlock.addStatement(it.genStmt()) + } + return irBlock } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/ArrayAccessAssignmentReceiver.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/ArrayAccessAssignmentReceiver.kt index b2ec980cb99..7e1cda441f4 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/ArrayAccessAssignmentReceiver.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/ArrayAccessAssignmentReceiver.kt @@ -38,7 +38,7 @@ class ArrayAccessAssignmentReceiver( override fun assign(withLValue: (LValue) -> IrExpression): IrExpression { val hasResult = operator.isAssignmentOperatorWithResult() val resultType = if (hasResult) type else callGenerator.context.builtIns.unitType - val irBlock = IrBlockImpl(startOffset, endOffset, resultType, hasResult, operator) + val irBlock = IrBlockImpl(startOffset, endOffset, resultType, operator) val irArrayValue = createRematerializableOrTemporary(callGenerator.scope, irArray, irBlock, "array") diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SafeCallReceiver.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SafeCallReceiver.kt index 628b789d59f..15e7fe6e731 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SafeCallReceiver.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SafeCallReceiver.kt @@ -51,7 +51,7 @@ class SafeCallReceiver( val irResult = withDispatchAndExtensionReceivers(dispatchReceiverValue, extensionReceiverValue) val resultType = irResult.type?.makeNullable() - val irBlock = IrBlockImpl(startOffset, endOffset, resultType, resultType != null, IrOperator.SAFE_CALL) + val irBlock = IrBlockImpl(startOffset, endOffset, resultType, IrOperator.SAFE_CALL) irBlock.addStatement(irTmp) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SimplePropertyLValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SimplePropertyLValue.kt index 9ac551b607b..f55d8f2542a 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SimplePropertyLValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/SimplePropertyLValue.kt @@ -79,7 +79,7 @@ class SimplePropertyLValue( irResultExpression } else { - val irBlock = IrBlockImpl(startOffset, endOffset, irResultExpression.type, irResultExpression.type != null, irOperator) + val irBlock = IrBlockImpl(startOffset, endOffset, irResultExpression.type, irOperator) irBlock.addAll(variablesForReceivers) irBlock.addStatement(irResultExpression) irBlock diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineDesugaredBlocks.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineDesugaredBlocks.kt index 521a71fd568..b1dc4d743ec 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineDesugaredBlocks.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineDesugaredBlocks.kt @@ -33,10 +33,7 @@ class InlineDesugaredBlocks : IrElementVisitor { } override fun visitBlock(expression: IrBlock, data: Nothing?) { - val transformedBlock = IrBlockImpl( - expression.startOffset, expression.endOffset, expression.type, - expression.hasResult, expression.operator - ) + val transformedBlock = IrBlockImpl(expression.startOffset, expression.endOffset, expression.type, expression.operator) for (statement in expression.statements) { statement.accept(this, data) if (statement is IrBlock && statement.operator != null) { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineSafeCallChains.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineSafeCallChains.kt index 940dcdfdec2..08830df9e4f 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineSafeCallChains.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InlineSafeCallChains.kt @@ -55,7 +55,7 @@ class InlineSafeCallChains(val context: GeneratorContext) : IrElementVisitor - - fun addChild(child: IrClassElement) } class IrClassImpl( @@ -42,7 +40,7 @@ class IrClassImpl( ) : IrDeclarationBase(startOffset, endOffset, originKind), IrClass { override val children: MutableList = ArrayList() - override fun addChild(child: IrClassElement) { + fun addElement(child: IrClassElement) { child.assertDetached() child.setTreeLocation(this, children.size) children.add(child) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt index f972ecea6ea..ec1c6bdc3dc 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBlock.kt @@ -23,7 +23,6 @@ import java.util.* interface IrBlock : IrExpression { - val hasResult: Boolean val operator: IrOperator? val statements: List @@ -37,7 +36,6 @@ class IrBlockImpl( startOffset: Int, endOffset: Int, type: KotlinType?, - override val hasResult: Boolean, override val operator: IrOperator? = null ) : IrExpressionBase(startOffset, endOffset, type), IrBlock { override val statements: MutableList = ArrayList() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBody.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBody.kt index d5c7ecbf679..ef4f24f7d8e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBody.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrBody.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.ir.expressions import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.visitors.IrElementVisitor +import java.util.* interface IrBody : IrElement @@ -25,15 +26,12 @@ interface IrExpressionBody : IrBody { var expression: IrExpression } -class IrExpressionBodyImpl( - startOffset: Int, - endOffset: Int -) : IrElementBase(startOffset, endOffset), IrExpressionBody { - constructor( - startOffset: Int, - endOffset: Int, - expression: IrExpression - ) : this(startOffset, endOffset) { +interface IrBlockBody : IrBody { + val statements: List +} + +class IrExpressionBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrExpressionBody { + constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset) { this.expression = expression } @@ -65,4 +63,36 @@ class IrExpressionBodyImpl( override fun acceptChildren(visitor: IrElementVisitor, data: D) { expression.accept(visitor, data) } +} + +class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrBlockBody { + override val statements: MutableList = ArrayList() + + fun addStatement(statement: IrStatement) { + statement.assertDetached() + statement.setTreeLocation(this, statements.size) + statements.add(statement) + } + + override fun getChild(slot: Int): IrElement? = + statements.getOrNull(slot) + + override fun replaceChild(slot: Int, newChild: IrElement) { + if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot) + + newChild.assertDetached() + statements[slot].detach() + statements[slot] = newChild.assertCast() + newChild.setTreeLocation(this, slot) + } + + override fun accept(visitor: IrElementVisitor, data: D): R { + return visitor.visitBlockBody(this, data) + } + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + statements.forEach { it.accept(visitor, data) } + } + + } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrOperator.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrOperator.kt index c941bb70a9f..0aa2938845e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrOperator.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrOperator.kt @@ -68,7 +68,8 @@ interface IrOperator { object DIVEQ : IrOperatorImpl("DIVEQ") object PERCEQ : IrOperatorImpl("PERCEQ") - object SYNTHETIC_BLOCK : IrOperatorImpl("SYNTHETIC_BLOCK") + object ARGUMENTS_REORDERING_FOR_CALL : IrOperatorImpl("ARGUMENTS_REORDERING_FOR_CALL") + object DESTRUCTURING_DECLARATION : IrOperatorImpl("DESTRUCTURING_DECLARATION") object GET_PROPERTY : IrOperatorImpl("GET_PROPERTY") object SET_PROPERTY : IrOperatorImpl("SET_PROPERTY") 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 17d50273232..3aa33a6ee88 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 @@ -37,25 +37,28 @@ class RenderIrElementVisitor : IrElementVisitor { "? ${declaration.javaClass.simpleName} ${declaration.descriptor?.name}" override fun visitFile(declaration: IrFile, data: Nothing?): String = - "IrFile ${declaration.name}" + "FILE ${declaration.name}" override fun visitFunction(declaration: IrFunction, data: Nothing?): String = - "IrFunction ${declaration.descriptor.render()}" + "FUN ${declaration.descriptor.render()}" override fun visitProperty(declaration: IrProperty, data: Nothing?): String = - "IrProperty ${declaration.descriptor.render()} getter=${declaration.getter?.name()} setter=${declaration.setter?.name()}" + "PROPERTY ${declaration.descriptor.render()} getter=${declaration.getter?.name()} setter=${declaration.setter?.name()}" override fun visitPropertyGetter(declaration: IrPropertyGetter, data: Nothing?): String = - "IrPropertyGetter ${declaration.descriptor.render()} property=${declaration.property?.name()}" + "PROPERTY_GETTER ${declaration.descriptor.render()} property=${declaration.property?.name()}" override fun visitPropertySetter(declaration: IrPropertySetter, data: Nothing?): String = - "IrPropertySetter ${declaration.descriptor.render()} property=${declaration.property?.name()}" + "PROPERTY_SETTER ${declaration.descriptor.render()} property=${declaration.property?.name()}" override fun visitVariable(declaration: IrVariable, data: Nothing?): String = "VAR ${declaration.descriptor.render()}" override fun visitExpressionBody(body: IrExpressionBody, data: Nothing?): String = - "IrExpressionBody" + "EXPRESSION_BODY" + + override fun visitBlockBody(body: IrBlockBody, data: Nothing?): String = + "BLOCK_BODY" override fun visitExpression(expression: IrExpression, data: Nothing?): String = "? ${expression.javaClass.simpleName} type=${expression.renderType()}" @@ -64,7 +67,7 @@ class RenderIrElementVisitor : IrElementVisitor { "CONST ${expression.kind} type=${expression.renderType()} value='${expression.value}'" override fun visitBlock(expression: IrBlock, data: Nothing?): String = - "BLOCK type=${expression.renderType()} hasResult=${expression.hasResult} operator=${expression.operator}" + "BLOCK type=${expression.renderType()} operator=${expression.operator}" override fun visitReturn(expression: IrReturn, data: Nothing?): String = "RETURN type=${expression.renderType()}" 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 5d133456f62..ef2c02e82a9 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 @@ -37,6 +37,8 @@ interface IrElementVisitor { fun visitBody(body: IrBody, data: D): R = visitElement(body, data) fun visitExpressionBody(body: IrExpressionBody, data: D): R = visitBody(body, data) + fun visitBlockBody(body: IrBlockBody, data: D) = visitBody(body, data) + fun visitExpression(expression: IrExpression, data: D): R = visitElement(expression, data) fun visitConst(expression: IrConst, data: D): R = visitExpression(expression, data) @@ -71,6 +73,4 @@ interface IrElementVisitor { // NB Use it only for testing purposes; will be removed as soon as all Kotlin expression types are covered fun visitDummyDeclaration(declaration: IrDummyDeclaration, data: D) = visitDeclaration(declaration, data) fun visitDummyExpression(expression: IrDummyExpression, data: D) = visitExpression(expression, data) - - } diff --git a/compiler/testData/ir/irText/arrayAccess.txt b/compiler/testData/ir/irText/arrayAccess.txt index 53d51cbc75e..07d898bd8ca 100644 --- a/compiler/testData/ir/irText/arrayAccess.txt +++ b/compiler/testData/ir/irText/arrayAccess.txt @@ -1,24 +1,22 @@ -IrFile /arrayAccess.kt - IrProperty public val p: kotlin.Int = 0 getter=null setter=null - IrExpressionBody +FILE /arrayAccess.kt + PROPERTY public val p: kotlin.Int = 0 getter=null setter=null + EXPRESSION_BODY CONST Int type=kotlin.Int value='0' - IrFunction public fun foo(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='1' - IrFunction public fun test(/*0*/ a: kotlin.IntArray): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .plus type=kotlin.Int operator=PLUS - $this: CALL .plus type=kotlin.Int operator=PLUS - $this: CALL .get type=kotlin.Int operator=GET_ARRAY_ELEMENT - $this: GET_VAR a type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='0' - other: CALL .get type=kotlin.Int operator=GET_ARRAY_ELEMENT - $this: GET_VAR a type=kotlin.IntArray operator=null - index: CALL . type=kotlin.Int operator=GET_PROPERTY + FUN public fun foo(): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='1' + FUN public fun test(/*0*/ a: kotlin.IntArray): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .plus type=kotlin.Int operator=PLUS + $this: CALL .plus type=kotlin.Int operator=PLUS + $this: CALL .get type=kotlin.Int operator=GET_ARRAY_ELEMENT + $this: GET_VAR a type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='0' other: CALL .get type=kotlin.Int operator=GET_ARRAY_ELEMENT $this: GET_VAR a type=kotlin.IntArray operator=null - index: CALL .foo type=kotlin.Int operator=null + index: CALL . type=kotlin.Int operator=GET_PROPERTY + other: CALL .get type=kotlin.Int operator=GET_ARRAY_ELEMENT + $this: GET_VAR a type=kotlin.IntArray operator=null + index: CALL .foo type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/arrayAssignment.txt b/compiler/testData/ir/irText/arrayAssignment.txt index f229aa409ab..6a811513052 100644 --- a/compiler/testData/ir/irText/arrayAssignment.txt +++ b/compiler/testData/ir/irText/arrayAssignment.txt @@ -1,26 +1,23 @@ -IrFile /arrayAssignment.kt - IrFunction public fun test(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR val x: kotlin.IntArray - CALL .intArrayOf type=kotlin.IntArray operator=null - elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray - DUMMY vararg type=kotlin.Int - CALL .set type=kotlin.Unit operator=EQ - $this: GET_VAR x type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='1' - value: CONST Int type=kotlin.Int value='0' - IrFunction public fun foo(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='1' - IrFunction public fun test2(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - CALL .set type=kotlin.Unit operator=EQ - $this: CALL .intArrayOf type=kotlin.IntArray operator=null - elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray - DUMMY vararg type=kotlin.Int - index: CALL .foo type=kotlin.Int operator=null - value: CONST Int type=kotlin.Int value='1' +FILE /arrayAssignment.kt + FUN public fun test(): kotlin.Unit + BLOCK_BODY + VAR val x: kotlin.IntArray + CALL .intArrayOf type=kotlin.IntArray operator=null + elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray + DUMMY vararg type=kotlin.Int + CALL .set type=kotlin.Unit operator=EQ + $this: GET_VAR x type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='1' + value: CONST Int type=kotlin.Int value='0' + FUN public fun foo(): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='1' + FUN public fun test2(): kotlin.Unit + BLOCK_BODY + CALL .set type=kotlin.Unit operator=EQ + $this: CALL .intArrayOf type=kotlin.IntArray operator=null + elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray + DUMMY vararg type=kotlin.Int + index: CALL .foo type=kotlin.Int operator=null + value: CONST Int type=kotlin.Int value='1' diff --git a/compiler/testData/ir/irText/arrayAugmentedAssignment1.txt b/compiler/testData/ir/irText/arrayAugmentedAssignment1.txt index ca52b47de20..f2590048a63 100644 --- a/compiler/testData/ir/irText/arrayAugmentedAssignment1.txt +++ b/compiler/testData/ir/irText/arrayAugmentedAssignment1.txt @@ -1,61 +1,56 @@ -IrFile /arrayAugmentedAssignment1.kt - IrFunction public fun foo(): kotlin.IntArray - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .intArrayOf type=kotlin.IntArray operator=null - elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray - DUMMY vararg type=kotlin.Int - IrFunction public fun bar(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='42' +FILE /arrayAugmentedAssignment1.kt + FUN public fun foo(): kotlin.IntArray + BLOCK_BODY + RETURN type= + CALL .intArrayOf type=kotlin.IntArray operator=null + elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray + DUMMY vararg type=kotlin.Int + FUN public fun bar(): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='42' DUMMY C - IrFunction public fun testVariable(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR var x: kotlin.IntArray - CALL .foo type=kotlin.IntArray operator=null - BLOCK type=kotlin.Unit hasResult=false operator=PLUSEQ - CALL .set type=kotlin.Unit operator=PLUSEQ - $this: GET_VAR x type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='0' - value: CALL .plus type=kotlin.Int operator=PLUSEQ - $this: CALL .get type=kotlin.Int operator=PLUSEQ - $this: GET_VAR x type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='0' - other: CONST Int type=kotlin.Int value='1' - IrFunction public fun testCall(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=MULTEQ - VAR val tmp0_array: kotlin.IntArray - CALL .foo type=kotlin.IntArray operator=null - VAR val tmp1_index0: kotlin.Int - CALL .bar type=kotlin.Int operator=null - CALL .set type=kotlin.Unit operator=MULTEQ - $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null - index: GET_VAR tmp1_index0 type=kotlin.Int operator=null - value: CALL .times type=kotlin.Int operator=MULTEQ - $this: CALL .get type=kotlin.Int operator=MULTEQ - $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null - index: GET_VAR tmp1_index0 type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='2' - IrFunction public fun testMember(/*0*/ c: C): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp0_array: kotlin.IntArray - CALL . type=kotlin.IntArray operator=GET_PROPERTY - $this: GET_VAR c type=C operator=null - VAR val tmp1: kotlin.Int - CALL .get type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null + FUN public fun testVariable(): kotlin.Unit + BLOCK_BODY + VAR var x: kotlin.IntArray + CALL .foo type=kotlin.IntArray operator=null + BLOCK type=kotlin.Unit operator=PLUSEQ + CALL .set type=kotlin.Unit operator=PLUSEQ + $this: GET_VAR x type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='0' + value: CALL .plus type=kotlin.Int operator=PLUSEQ + $this: CALL .get type=kotlin.Int operator=PLUSEQ + $this: GET_VAR x type=kotlin.IntArray operator=null index: CONST Int type=kotlin.Int value='0' - CALL .set type=kotlin.Unit operator=POSTFIX_INCR + other: CONST Int type=kotlin.Int value='1' + FUN public fun testCall(): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=MULTEQ + VAR val tmp0_array: kotlin.IntArray + CALL .foo type=kotlin.IntArray operator=null + VAR val tmp1_index0: kotlin.Int + CALL .bar type=kotlin.Int operator=null + CALL .set type=kotlin.Unit operator=MULTEQ + $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null + index: GET_VAR tmp1_index0 type=kotlin.Int operator=null + value: CALL .times type=kotlin.Int operator=MULTEQ + $this: CALL .get type=kotlin.Int operator=MULTEQ + $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null + index: GET_VAR tmp1_index0 type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='2' + FUN public fun testMember(/*0*/ c: C): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp0_array: kotlin.IntArray + CALL . type=kotlin.IntArray operator=GET_PROPERTY + $this: GET_VAR c type=C operator=null + VAR val tmp1: kotlin.Int + CALL .get type=kotlin.Int operator=POSTFIX_INCR $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null index: CONST Int type=kotlin.Int value='0' - value: CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp1 type=kotlin.Int operator=null - GET_VAR tmp1 type=kotlin.Int operator=null + CALL .set type=kotlin.Unit operator=POSTFIX_INCR + $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='0' + value: CALL .inc type=kotlin.Int operator=POSTFIX_INCR + $this: GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp1 type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/arrayAugmentedAssignment2.txt b/compiler/testData/ir/irText/arrayAugmentedAssignment2.txt index a1ce3539c94..d7dbe5fe099 100644 --- a/compiler/testData/ir/irText/arrayAugmentedAssignment2.txt +++ b/compiler/testData/ir/irText/arrayAugmentedAssignment2.txt @@ -1,16 +1,15 @@ -IrFile /arrayAugmentedAssignment2.kt +FILE /arrayAugmentedAssignment2.kt DUMMY IA DUMMY IB - IrFunction public fun IB.test(/*0*/ a: IA): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=PLUSEQ - CALL .set type=kotlin.Unit operator=PLUSEQ - $this: $RECEIVER of: test type=IB - $receiver: GET_VAR a type=IA operator=null - index: CONST String type=kotlin.String value='' - value: CALL .plus type=kotlin.Int operator=PLUSEQ - $this: CALL .get type=kotlin.Int operator=PLUSEQ - $this: GET_VAR a type=IA operator=null - index: CONST String type=kotlin.String value='' - other: CONST Int type=kotlin.Int value='42' + FUN public fun IB.test(/*0*/ a: IA): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=PLUSEQ + CALL .set type=kotlin.Unit operator=PLUSEQ + $this: $RECEIVER of: test type=IB + $receiver: GET_VAR a type=IA operator=null + index: CONST String type=kotlin.String value='' + value: CALL .plus type=kotlin.Int operator=PLUSEQ + $this: CALL .get type=kotlin.Int operator=PLUSEQ + $this: GET_VAR a type=IA operator=null + index: CONST String type=kotlin.String value='' + other: CONST Int type=kotlin.Int value='42' diff --git a/compiler/testData/ir/irText/assignments.txt b/compiler/testData/ir/irText/assignments.txt index 3b9e36b6410..3f78304e100 100644 --- a/compiler/testData/ir/irText/assignments.txt +++ b/compiler/testData/ir/irText/assignments.txt @@ -1,19 +1,17 @@ -IrFile /assignments.kt +FILE /assignments.kt DUMMY Ref - IrFunction public fun test1(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR var x: kotlin.Int - CONST Int type=kotlin.Int value='0' - SET_VAR x type= operator=EQ - CONST Int type=kotlin.Int value='1' - SET_VAR x type= operator=EQ - CALL .plus type=kotlin.Int operator=PLUS - $this: GET_VAR x type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='1' - IrFunction public fun test2(/*0*/ r: Ref): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - CALL . type=kotlin.Unit operator=EQ - $this: GET_VAR r type=Ref operator=null - : CONST Int type=kotlin.Int value='0' + FUN public fun test1(): kotlin.Unit + BLOCK_BODY + VAR var x: kotlin.Int + CONST Int type=kotlin.Int value='0' + SET_VAR x type= operator=EQ + CONST Int type=kotlin.Int value='1' + SET_VAR x type= operator=EQ + CALL .plus type=kotlin.Int operator=PLUS + $this: GET_VAR x type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='1' + FUN public fun test2(/*0*/ r: Ref): kotlin.Unit + BLOCK_BODY + CALL . type=kotlin.Unit operator=EQ + $this: GET_VAR r type=Ref operator=null + : CONST Int type=kotlin.Int value='0' diff --git a/compiler/testData/ir/irText/augmentedAssignment1.txt b/compiler/testData/ir/irText/augmentedAssignment1.txt index 4d4f8badf43..b34bc90f98a 100644 --- a/compiler/testData/ir/irText/augmentedAssignment1.txt +++ b/compiler/testData/ir/irText/augmentedAssignment1.txt @@ -1,52 +1,50 @@ -IrFile /augmentedAssignment1.kt - IrProperty public var p: kotlin.Int getter=null setter=null - IrExpressionBody +FILE /augmentedAssignment1.kt + PROPERTY public var p: kotlin.Int getter=null setter=null + EXPRESSION_BODY CONST Int type=kotlin.Int value='0' - IrFunction public fun testVariable(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR var x: kotlin.Int - CONST Int type=kotlin.Int value='0' - SET_VAR x type= operator=PLUSEQ - CALL .plus type=kotlin.Int operator=PLUSEQ - $this: GET_VAR x type=kotlin.Int operator=PLUSEQ - other: CONST Int type=kotlin.Int value='1' - SET_VAR x type= operator=MINUSEQ - CALL .minus type=kotlin.Int operator=MINUSEQ - $this: GET_VAR x type=kotlin.Int operator=MINUSEQ - other: CONST Int type=kotlin.Int value='2' - SET_VAR x type= operator=MULTEQ - CALL .times type=kotlin.Int operator=MULTEQ - $this: GET_VAR x type=kotlin.Int operator=MULTEQ - other: CONST Int type=kotlin.Int value='3' - SET_VAR x type= operator=DIVEQ - CALL .div type=kotlin.Int operator=DIVEQ - $this: GET_VAR x type=kotlin.Int operator=DIVEQ - other: CONST Int type=kotlin.Int value='4' - SET_VAR x type= operator=PERCEQ - CALL .mod type=kotlin.Int operator=PERCEQ - $this: GET_VAR x type=kotlin.Int operator=PERCEQ - other: CONST Int type=kotlin.Int value='5' - IrFunction public fun testProperty(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - CALL . type=kotlin.Unit operator=PLUSEQ - : CALL .plus type=kotlin.Int operator=PLUSEQ - $this: CALL . type=kotlin.Int operator=PLUSEQ - other: CONST Int type=kotlin.Int value='1' - CALL . type=kotlin.Unit operator=MINUSEQ - : CALL .minus type=kotlin.Int operator=MINUSEQ - $this: CALL . type=kotlin.Int operator=MINUSEQ - other: CONST Int type=kotlin.Int value='2' - CALL . type=kotlin.Unit operator=MULTEQ - : CALL .times type=kotlin.Int operator=MULTEQ - $this: CALL . type=kotlin.Int operator=MULTEQ - other: CONST Int type=kotlin.Int value='3' - CALL . type=kotlin.Unit operator=DIVEQ - : CALL .div type=kotlin.Int operator=DIVEQ - $this: CALL . type=kotlin.Int operator=DIVEQ - other: CONST Int type=kotlin.Int value='4' - CALL . type=kotlin.Unit operator=PERCEQ - : CALL .mod type=kotlin.Int operator=PERCEQ - $this: CALL . type=kotlin.Int operator=PERCEQ - other: CONST Int type=kotlin.Int value='5' + FUN public fun testVariable(): kotlin.Unit + BLOCK_BODY + VAR var x: kotlin.Int + CONST Int type=kotlin.Int value='0' + SET_VAR x type= operator=PLUSEQ + CALL .plus type=kotlin.Int operator=PLUSEQ + $this: GET_VAR x type=kotlin.Int operator=PLUSEQ + other: CONST Int type=kotlin.Int value='1' + SET_VAR x type= operator=MINUSEQ + CALL .minus type=kotlin.Int operator=MINUSEQ + $this: GET_VAR x type=kotlin.Int operator=MINUSEQ + other: CONST Int type=kotlin.Int value='2' + SET_VAR x type= operator=MULTEQ + CALL .times type=kotlin.Int operator=MULTEQ + $this: GET_VAR x type=kotlin.Int operator=MULTEQ + other: CONST Int type=kotlin.Int value='3' + SET_VAR x type= operator=DIVEQ + CALL .div type=kotlin.Int operator=DIVEQ + $this: GET_VAR x type=kotlin.Int operator=DIVEQ + other: CONST Int type=kotlin.Int value='4' + SET_VAR x type= operator=PERCEQ + CALL .mod type=kotlin.Int operator=PERCEQ + $this: GET_VAR x type=kotlin.Int operator=PERCEQ + other: CONST Int type=kotlin.Int value='5' + FUN public fun testProperty(): kotlin.Unit + BLOCK_BODY + CALL . type=kotlin.Unit operator=PLUSEQ + : CALL .plus type=kotlin.Int operator=PLUSEQ + $this: CALL . type=kotlin.Int operator=PLUSEQ + other: CONST Int type=kotlin.Int value='1' + CALL . type=kotlin.Unit operator=MINUSEQ + : CALL .minus type=kotlin.Int operator=MINUSEQ + $this: CALL . type=kotlin.Int operator=MINUSEQ + other: CONST Int type=kotlin.Int value='2' + CALL . type=kotlin.Unit operator=MULTEQ + : CALL .times type=kotlin.Int operator=MULTEQ + $this: CALL . type=kotlin.Int operator=MULTEQ + other: CONST Int type=kotlin.Int value='3' + CALL . type=kotlin.Unit operator=DIVEQ + : CALL .div type=kotlin.Int operator=DIVEQ + $this: CALL . type=kotlin.Int operator=DIVEQ + other: CONST Int type=kotlin.Int value='4' + CALL . type=kotlin.Unit operator=PERCEQ + : CALL .mod type=kotlin.Int operator=PERCEQ + $this: CALL . type=kotlin.Int operator=PERCEQ + other: CONST Int type=kotlin.Int value='5' diff --git a/compiler/testData/ir/irText/augmentedAssignment2.txt b/compiler/testData/ir/irText/augmentedAssignment2.txt index 4df57de3b08..bdf0bc5865c 100644 --- a/compiler/testData/ir/irText/augmentedAssignment2.txt +++ b/compiler/testData/ir/irText/augmentedAssignment2.txt @@ -1,58 +1,51 @@ -IrFile /augmentedAssignment2.kt +FILE /augmentedAssignment2.kt DUMMY A - IrFunction public operator fun A.plusAssign(/*0*/ s: kotlin.String): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public operator fun A.minusAssign(/*0*/ s: kotlin.String): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public operator fun A.timesAssign(/*0*/ s: kotlin.String): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public operator fun A.divAssign(/*0*/ s: kotlin.String): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public operator fun A.modAssign(/*0*/ s: kotlin.String): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrProperty public val p: A getter=null setter=null - IrExpressionBody + 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 + BLOCK_BODY + FUN public operator fun A.timesAssign(/*0*/ s: kotlin.String): kotlin.Unit + BLOCK_BODY + FUN public operator fun A.divAssign(/*0*/ s: kotlin.String): kotlin.Unit + BLOCK_BODY + FUN public operator fun A.modAssign(/*0*/ s: kotlin.String): kotlin.Unit + BLOCK_BODY + PROPERTY public val p: A getter=null setter=null + EXPRESSION_BODY CALL . type=A operator=null - IrFunction public fun testVariable(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR val a: A - CALL . type=A operator=null - CALL .plusAssign type=kotlin.Unit operator=PLUSEQ - $receiver: GET_VAR a type=A operator=PLUSEQ - s: CONST String type=kotlin.String value='+=' - CALL .minusAssign type=kotlin.Unit operator=MINUSEQ - $receiver: GET_VAR a type=A operator=MINUSEQ - s: CONST String type=kotlin.String value='-=' - CALL .timesAssign type=kotlin.Unit operator=MULTEQ - $receiver: GET_VAR a type=A operator=MULTEQ - s: CONST String type=kotlin.String value='*=' - CALL .divAssign type=kotlin.Unit operator=DIVEQ - $receiver: GET_VAR a type=A operator=DIVEQ - s: CONST String type=kotlin.String value='/=' - CALL .modAssign type=kotlin.Unit operator=PERCEQ - $receiver: GET_VAR a type=A operator=PERCEQ - s: CONST String type=kotlin.String value='*=' - IrFunction public fun testProperty(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - CALL .plusAssign type=kotlin.Unit operator=PLUSEQ - $receiver: CALL . type=A operator=PLUSEQ - s: CONST String type=kotlin.String value='+=' - CALL .minusAssign type=kotlin.Unit operator=MINUSEQ - $receiver: CALL . type=A operator=MINUSEQ - s: CONST String type=kotlin.String value='-=' - CALL .timesAssign type=kotlin.Unit operator=MULTEQ - $receiver: CALL . type=A operator=MULTEQ - s: CONST String type=kotlin.String value='*=' - CALL .divAssign type=kotlin.Unit operator=DIVEQ - $receiver: CALL . type=A operator=DIVEQ - s: CONST String type=kotlin.String value='/=' - CALL .modAssign type=kotlin.Unit operator=PERCEQ - $receiver: CALL . type=A operator=PERCEQ - s: CONST String type=kotlin.String value='%=' + FUN public fun testVariable(): kotlin.Unit + BLOCK_BODY + VAR val a: A + CALL . type=A operator=null + CALL .plusAssign type=kotlin.Unit operator=PLUSEQ + $receiver: GET_VAR a type=A operator=PLUSEQ + s: CONST String type=kotlin.String value='+=' + CALL .minusAssign type=kotlin.Unit operator=MINUSEQ + $receiver: GET_VAR a type=A operator=MINUSEQ + s: CONST String type=kotlin.String value='-=' + CALL .timesAssign type=kotlin.Unit operator=MULTEQ + $receiver: GET_VAR a type=A operator=MULTEQ + s: CONST String type=kotlin.String value='*=' + CALL .divAssign type=kotlin.Unit operator=DIVEQ + $receiver: GET_VAR a type=A operator=DIVEQ + s: CONST String type=kotlin.String value='/=' + CALL .modAssign type=kotlin.Unit operator=PERCEQ + $receiver: GET_VAR a type=A operator=PERCEQ + s: CONST String type=kotlin.String value='*=' + FUN public fun testProperty(): kotlin.Unit + BLOCK_BODY + CALL .plusAssign type=kotlin.Unit operator=PLUSEQ + $receiver: CALL . type=A operator=PLUSEQ + s: CONST String type=kotlin.String value='+=' + CALL .minusAssign type=kotlin.Unit operator=MINUSEQ + $receiver: CALL . type=A operator=MINUSEQ + s: CONST String type=kotlin.String value='-=' + CALL .timesAssign type=kotlin.Unit operator=MULTEQ + $receiver: CALL . type=A operator=MULTEQ + s: CONST String type=kotlin.String value='*=' + CALL .divAssign type=kotlin.Unit operator=DIVEQ + $receiver: CALL . type=A operator=DIVEQ + s: CONST String type=kotlin.String value='/=' + CALL .modAssign type=kotlin.Unit operator=PERCEQ + $receiver: CALL . type=A operator=PERCEQ + s: CONST String type=kotlin.String value='%=' diff --git a/compiler/testData/ir/irText/booleanOperators.txt b/compiler/testData/ir/irText/booleanOperators.txt index 8b59b1309ea..e6ea539874a 100644 --- a/compiler/testData/ir/irText/booleanOperators.txt +++ b/compiler/testData/ir/irText/booleanOperators.txt @@ -1,31 +1,27 @@ -IrFile /booleanOperators.kt - IrFunction public fun test1(/*0*/ a: kotlin.Boolean, /*1*/ b: kotlin.Boolean): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Boolean operator=ANDAND - if: GET_VAR a type=kotlin.Boolean operator=null - then: GET_VAR b type=kotlin.Boolean operator=null - else: CONST Boolean type=kotlin.Boolean value='false' - IrFunction public fun test2(/*0*/ a: kotlin.Boolean, /*1*/ b: kotlin.Boolean): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Boolean operator=OROR - if: GET_VAR a type=kotlin.Boolean operator=null - then: CONST Boolean type=kotlin.Boolean value='true' - else: GET_VAR b type=kotlin.Boolean operator=null - IrFunction public fun test1x(/*0*/ a: kotlin.Boolean, /*1*/ b: kotlin.Boolean): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .and type=kotlin.Boolean operator=null - $this: GET_VAR a type=kotlin.Boolean operator=null - other: GET_VAR b type=kotlin.Boolean operator=null - IrFunction public fun test2x(/*0*/ a: kotlin.Boolean, /*1*/ b: kotlin.Boolean): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .or type=kotlin.Boolean operator=null - $this: GET_VAR a type=kotlin.Boolean operator=null - other: GET_VAR b type=kotlin.Boolean operator=null +FILE /booleanOperators.kt + FUN public fun test1(/*0*/ a: kotlin.Boolean, /*1*/ b: kotlin.Boolean): kotlin.Boolean + BLOCK_BODY + RETURN type= + WHEN type=kotlin.Boolean operator=ANDAND + if: GET_VAR a type=kotlin.Boolean operator=null + then: GET_VAR b type=kotlin.Boolean operator=null + else: CONST Boolean type=kotlin.Boolean value='false' + FUN public fun test2(/*0*/ a: kotlin.Boolean, /*1*/ b: kotlin.Boolean): kotlin.Boolean + BLOCK_BODY + RETURN type= + WHEN type=kotlin.Boolean operator=OROR + if: GET_VAR a type=kotlin.Boolean operator=null + then: CONST Boolean type=kotlin.Boolean value='true' + else: GET_VAR b type=kotlin.Boolean operator=null + FUN public fun test1x(/*0*/ a: kotlin.Boolean, /*1*/ b: kotlin.Boolean): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .and type=kotlin.Boolean operator=null + $this: GET_VAR a type=kotlin.Boolean operator=null + other: GET_VAR b type=kotlin.Boolean operator=null + FUN public fun test2x(/*0*/ a: kotlin.Boolean, /*1*/ b: kotlin.Boolean): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .or type=kotlin.Boolean operator=null + $this: GET_VAR a type=kotlin.Boolean operator=null + other: GET_VAR b type=kotlin.Boolean operator=null diff --git a/compiler/testData/ir/irText/boxOk.txt b/compiler/testData/ir/irText/boxOk.txt index 1182d9727d2..20f7ece0fce 100644 --- a/compiler/testData/ir/irText/boxOk.txt +++ b/compiler/testData/ir/irText/boxOk.txt @@ -1,6 +1,5 @@ -IrFile /boxOk.kt - IrFunction public fun box(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST String type=kotlin.String value='OK' +FILE /boxOk.kt + FUN public fun box(): kotlin.String + BLOCK_BODY + RETURN type= + CONST String type=kotlin.String value='OK' diff --git a/compiler/testData/ir/irText/breakContinue.txt b/compiler/testData/ir/irText/breakContinue.txt index 196f9b71e06..1031d7b0709 100644 --- a/compiler/testData/ir/irText/breakContinue.txt +++ b/compiler/testData/ir/irText/breakContinue.txt @@ -1,60 +1,57 @@ -IrFile /breakContinue.kt - IrFunction public fun test1(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHILE label=null operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - BREAK label=null depth=0 - DO_WHILE label=null operator=DO_WHILE_LOOP - body: BLOCK type= hasResult=false operator=null - BREAK label=null depth=0 - condition: CONST Boolean type=kotlin.Boolean value='true' - WHILE label=null operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - CONTINUE label=null depth=0 - DO_WHILE label=null operator=DO_WHILE_LOOP - body: BLOCK type= hasResult=false operator=null - CONTINUE label=null depth=0 - condition: CONST Boolean type=kotlin.Boolean value='true' - IrFunction public fun test2(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHILE label=OUTER operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - WHILE label=INNER operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - BREAK label=INNER depth=0 - BREAK label=OUTER depth=1 - BREAK label=OUTER depth=0 - WHILE label=OUTER operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - WHILE label=INNER operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - CONTINUE label=INNER depth=0 - CONTINUE label=OUTER depth=1 - CONTINUE label=OUTER depth=0 - IrFunction public fun test3(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHILE label=L operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - WHILE label=L operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - BREAK label=L depth=0 - BREAK label=L depth=0 - WHILE label=L operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - WHILE label=L operator=WHILE_LOOP - condition: CONST Boolean type=kotlin.Boolean value='true' - body: BLOCK type= hasResult=false operator=null - CONTINUE label=L depth=0 - CONTINUE label=L depth=0 +FILE /breakContinue.kt + FUN public fun test1(): kotlin.Unit + BLOCK_BODY + WHILE label=null operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + BREAK label=null depth=0 + DO_WHILE label=null operator=DO_WHILE_LOOP + body: BLOCK type=kotlin.Unit operator=null + BREAK label=null depth=0 + condition: CONST Boolean type=kotlin.Boolean value='true' + WHILE label=null operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + CONTINUE label=null depth=0 + DO_WHILE label=null operator=DO_WHILE_LOOP + body: BLOCK type=kotlin.Unit operator=null + CONTINUE label=null depth=0 + condition: CONST Boolean type=kotlin.Boolean value='true' + FUN public fun test2(): kotlin.Unit + BLOCK_BODY + WHILE label=OUTER operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + WHILE label=INNER operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + BREAK label=INNER depth=0 + BREAK label=OUTER depth=1 + BREAK label=OUTER depth=0 + WHILE label=OUTER operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + WHILE label=INNER operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + CONTINUE label=INNER depth=0 + CONTINUE label=OUTER depth=1 + CONTINUE label=OUTER depth=0 + FUN public fun test3(): kotlin.Unit + BLOCK_BODY + WHILE label=L operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + WHILE label=L operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + BREAK label=L depth=0 + BREAK label=L depth=0 + WHILE label=L operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + WHILE label=L operator=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value='true' + body: BLOCK type=kotlin.Nothing operator=null + CONTINUE label=L depth=0 + CONTINUE label=L depth=0 diff --git a/compiler/testData/ir/irText/callWithReorderedArguments.txt b/compiler/testData/ir/irText/callWithReorderedArguments.txt index 27917a8eb31..ec550fa533d 100644 --- a/compiler/testData/ir/irText/callWithReorderedArguments.txt +++ b/compiler/testData/ir/irText/callWithReorderedArguments.txt @@ -1,44 +1,38 @@ -IrFile /callWithReorderedArguments.kt - IrFunction public fun foo(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public fun noReorder1(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='1' - IrFunction public fun noReorder2(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='2' - IrFunction public fun reordered1(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='1' - IrFunction public fun reordered2(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='2' - IrFunction public fun test(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null +FILE /callWithReorderedArguments.kt + FUN public fun foo(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Unit + BLOCK_BODY + FUN public fun noReorder1(): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='1' + FUN public fun noReorder2(): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='2' + FUN public fun reordered1(): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='1' + FUN public fun reordered2(): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='2' + FUN public fun test(): kotlin.Unit + BLOCK_BODY + CALL .foo type=kotlin.Unit operator=null + a: CALL .noReorder1 type=kotlin.Int operator=null + b: CALL .noReorder2 type=kotlin.Int operator=null + BLOCK type=kotlin.Unit operator=ARGUMENTS_REORDERING_FOR_CALL + VAR val tmp0_b: kotlin.Int + CALL .reordered1 type=kotlin.Int operator=null + VAR val tmp1_a: kotlin.Int + CALL .reordered2 type=kotlin.Int operator=null CALL .foo type=kotlin.Unit operator=null - a: CALL .noReorder1 type=kotlin.Int operator=null - b: CALL .noReorder2 type=kotlin.Int operator=null - BLOCK type=kotlin.Unit hasResult=true operator=SYNTHETIC_BLOCK - VAR val tmp0_b: kotlin.Int - CALL .reordered1 type=kotlin.Int operator=null - VAR val tmp1_a: kotlin.Int - CALL .reordered2 type=kotlin.Int operator=null - CALL .foo type=kotlin.Unit operator=null - a: GET_VAR tmp1_a type=kotlin.Int operator=null - b: GET_VAR tmp0_b type=kotlin.Int operator=null - BLOCK type=kotlin.Unit hasResult=true operator=SYNTHETIC_BLOCK - VAR val tmp2_a: kotlin.Int - CALL .reordered2 type=kotlin.Int operator=null - CALL .foo type=kotlin.Unit operator=null - a: GET_VAR tmp2_a type=kotlin.Int operator=null - b: CONST Int type=kotlin.Int value='1' + a: GET_VAR tmp1_a type=kotlin.Int operator=null + b: GET_VAR tmp0_b type=kotlin.Int operator=null + BLOCK type=kotlin.Unit operator=ARGUMENTS_REORDERING_FOR_CALL + VAR val tmp2_a: kotlin.Int + CALL .reordered2 type=kotlin.Int operator=null + CALL .foo type=kotlin.Unit operator=null + a: GET_VAR tmp2_a type=kotlin.Int operator=null + b: CONST Int type=kotlin.Int value='1' diff --git a/compiler/testData/ir/irText/calls.txt b/compiler/testData/ir/irText/calls.txt index 34f7da84e07..c0b025ff34e 100644 --- a/compiler/testData/ir/irText/calls.txt +++ b/compiler/testData/ir/irText/calls.txt @@ -1,42 +1,36 @@ -IrFile /calls.kt - IrFunction public fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - GET_VAR x type=kotlin.Int operator=null - IrFunction public fun bar(/*0*/ x: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .foo type=kotlin.Int operator=null +FILE /calls.kt + FUN public fun foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + GET_VAR x type=kotlin.Int operator=null + FUN public fun bar(/*0*/ x: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .foo type=kotlin.Int operator=null + x: GET_VAR x type=kotlin.Int operator=null + y: CONST Int type=kotlin.Int value='1' + FUN public fun qux(/*0*/ x: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .foo type=kotlin.Int operator=null + x: CALL .foo type=kotlin.Int operator=null x: GET_VAR x type=kotlin.Int operator=null - y: CONST Int type=kotlin.Int value='1' - IrFunction public fun qux(/*0*/ x: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .foo type=kotlin.Int operator=null - x: CALL .foo type=kotlin.Int operator=null - x: GET_VAR x type=kotlin.Int operator=null - y: GET_VAR x type=kotlin.Int operator=null - y: GET_VAR x type=kotlin.Int operator=null - IrFunction public fun kotlin.Int.ext1(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - $RECEIVER of: ext1 type=kotlin.Int - IrFunction public fun kotlin.Int.ext2(/*0*/ x: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .foo type=kotlin.Int operator=null - x: $RECEIVER of: ext2 type=kotlin.Int - y: GET_VAR x type=kotlin.Int operator=null - IrFunction public fun kotlin.Int.ext3(/*0*/ x: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .foo type=kotlin.Int operator=null - x: CALL .ext1 type=kotlin.Int operator=null - $receiver: $RECEIVER of: ext3 type=kotlin.Int y: GET_VAR x type=kotlin.Int operator=null + y: GET_VAR x type=kotlin.Int operator=null + FUN public fun kotlin.Int.ext1(): kotlin.Int + BLOCK_BODY + RETURN type= + $RECEIVER of: ext1 type=kotlin.Int + FUN public fun kotlin.Int.ext2(/*0*/ x: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .foo type=kotlin.Int operator=null + x: $RECEIVER of: ext2 type=kotlin.Int + y: GET_VAR x type=kotlin.Int operator=null + FUN public fun kotlin.Int.ext3(/*0*/ x: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .foo type=kotlin.Int operator=null + x: CALL .ext1 type=kotlin.Int operator=null + $receiver: $RECEIVER of: ext3 type=kotlin.Int + y: GET_VAR x type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/chainOfSafeCalls.txt b/compiler/testData/ir/irText/chainOfSafeCalls.txt index 6d9f672a811..54c9f185096 100644 --- a/compiler/testData/ir/irText/chainOfSafeCalls.txt +++ b/compiler/testData/ir/irText/chainOfSafeCalls.txt @@ -1,24 +1,23 @@ -IrFile /chainOfSafeCalls.kt +FILE /chainOfSafeCalls.kt DUMMY C - IrFunction public fun test(/*0*/ nc: C?): C? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - BLOCK type=C? hasResult=true operator=SAFE_CALL - VAR val tmp2_safe_receiver: C? - WHEN type=C? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR nc type=C? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL .bar type=C? operator=null - $this: CALL .foo type=C operator=null - $this: GET_VAR nc type=C? operator=null + FUN public fun test(/*0*/ nc: C?): C? + BLOCK_BODY + RETURN type= + BLOCK type=C? operator=SAFE_CALL + VAR val tmp2_safe_receiver: C? WHEN type=C? operator=SAFE_CALL if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp2_safe_receiver type=C? operator=null + arg0: GET_VAR nc type=C? operator=null arg1: CONST Null type=kotlin.Nothing? value='null' then: CONST Null type=kotlin.Nothing? value='null' - else: CALL .foo type=C operator=null + else: CALL .bar type=C? operator=null $this: CALL .foo type=C operator=null - $this: GET_VAR tmp2_safe_receiver type=C? operator=null + $this: GET_VAR nc type=C? operator=null + WHEN type=C? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR tmp2_safe_receiver type=C? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: CALL .foo type=C operator=null + $this: CALL .foo type=C operator=null + $this: GET_VAR tmp2_safe_receiver type=C? operator=null diff --git a/compiler/testData/ir/irText/conventionComparisons.txt b/compiler/testData/ir/irText/conventionComparisons.txt index 74e03186403..f24af563f91 100644 --- a/compiler/testData/ir/irText/conventionComparisons.txt +++ b/compiler/testData/ir/irText/conventionComparisons.txt @@ -1,39 +1,35 @@ -IrFile /conventionComparisons.kt +FILE /conventionComparisons.kt DUMMY IA DUMMY IB - IrFunction public fun IB.test1(/*0*/ a1: IA, /*1*/ a2: IA): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: $RECEIVER of: test1 type=IB - $receiver: GET_VAR a1 type=IA operator=null - other: GET_VAR a2 type=IA operator=null - IrFunction public fun IB.test2(/*0*/ a1: IA, /*1*/ a2: IA): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ - arg0: CALL .compareTo type=kotlin.Int operator=GTEQ - $this: $RECEIVER of: test2 type=IB - $receiver: GET_VAR a1 type=IA operator=null - other: GET_VAR a2 type=IA operator=null - IrFunction public fun IB.test3(/*0*/ a1: IA, /*1*/ a2: IA): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: $RECEIVER of: test3 type=IB - $receiver: GET_VAR a1 type=IA operator=null - other: GET_VAR a2 type=IA operator=null - IrFunction public fun IB.test4(/*0*/ a1: IA, /*1*/ a2: IA): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ - arg0: CALL .compareTo type=kotlin.Int operator=LTEQ - $this: $RECEIVER of: test4 type=IB - $receiver: GET_VAR a1 type=IA operator=null - other: GET_VAR a2 type=IA operator=null + FUN public fun IB.test1(/*0*/ a1: IA, /*1*/ a2: IA): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: $RECEIVER of: test1 type=IB + $receiver: GET_VAR a1 type=IA operator=null + other: GET_VAR a2 type=IA operator=null + FUN public fun IB.test2(/*0*/ a1: IA, /*1*/ a2: IA): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ + arg0: CALL .compareTo type=kotlin.Int operator=GTEQ + $this: $RECEIVER of: test2 type=IB + $receiver: GET_VAR a1 type=IA operator=null + other: GET_VAR a2 type=IA operator=null + FUN public fun IB.test3(/*0*/ a1: IA, /*1*/ a2: IA): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: $RECEIVER of: test3 type=IB + $receiver: GET_VAR a1 type=IA operator=null + other: GET_VAR a2 type=IA operator=null + FUN public fun IB.test4(/*0*/ a1: IA, /*1*/ a2: IA): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ + arg0: CALL .compareTo type=kotlin.Int operator=LTEQ + $this: $RECEIVER of: test4 type=IB + $receiver: GET_VAR a1 type=IA operator=null + other: GET_VAR a2 type=IA operator=null diff --git a/compiler/testData/ir/irText/destructuring1.txt b/compiler/testData/ir/irText/destructuring1.txt index 175eae47c69..00321f3b307 100644 --- a/compiler/testData/ir/irText/destructuring1.txt +++ b/compiler/testData/ir/irText/destructuring1.txt @@ -1,14 +1,13 @@ -IrFunction public fun B.test(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type= hasResult=false operator=SYNTHETIC_BLOCK - VAR val tmp0_container: A - GET_OBJECT A type=A - VAR val x: kotlin.Int - CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1) - $this: $RECEIVER of: test type=B - $receiver: GET_VAR tmp0_container type=A operator=null - VAR val y: kotlin.Int - CALL .component2 type=kotlin.Int operator=COMPONENT_N(index=2) - $this: $RECEIVER of: test type=B - $receiver: GET_VAR tmp0_container type=A operator=null +FUN public fun B.test(): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=DESTRUCTURING_DECLARATION + VAR val tmp0_container: A + GET_OBJECT A type=A + VAR val x: kotlin.Int + CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1) + $this: $RECEIVER of: test type=B + $receiver: GET_VAR tmp0_container type=A operator=null + VAR val y: kotlin.Int + CALL .component2 type=kotlin.Int operator=COMPONENT_N(index=2) + $this: $RECEIVER of: test type=B + $receiver: GET_VAR tmp0_container type=A operator=null diff --git a/compiler/testData/ir/irText/dotQualified.txt b/compiler/testData/ir/irText/dotQualified.txt index 6bf0ed48a44..46dd94ccd98 100644 --- a/compiler/testData/ir/irText/dotQualified.txt +++ b/compiler/testData/ir/irText/dotQualified.txt @@ -1,18 +1,16 @@ -IrFile /dotQualified.kt - IrFunction public fun length(/*0*/ s: kotlin.String): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL . type=kotlin.Int operator=GET_PROPERTY - $this: GET_VAR s type=kotlin.String operator=null - IrFunction public fun lengthN(/*0*/ s: kotlin.String?): kotlin.Int? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Int? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR s type=kotlin.String? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL . type=kotlin.Int operator=GET_PROPERTY - $this: GET_VAR s type=kotlin.String? operator=null +FILE /dotQualified.kt + FUN public fun length(/*0*/ s: kotlin.String): kotlin.Int + BLOCK_BODY + RETURN type= + CALL . type=kotlin.Int operator=GET_PROPERTY + $this: GET_VAR s type=kotlin.String operator=null + FUN public fun lengthN(/*0*/ s: kotlin.String?): kotlin.Int? + BLOCK_BODY + RETURN type= + WHEN type=kotlin.Int? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR s type=kotlin.String? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: CALL . type=kotlin.Int operator=GET_PROPERTY + $this: GET_VAR s type=kotlin.String? operator=null diff --git a/compiler/testData/ir/irText/elvis.txt b/compiler/testData/ir/irText/elvis.txt index 36929a74b02..9f9924d3aff 100644 --- a/compiler/testData/ir/irText/elvis.txt +++ b/compiler/testData/ir/irText/elvis.txt @@ -1,80 +1,74 @@ -IrFile /elvis.kt - IrProperty public val p: kotlin.Any? = null getter=null setter=null - IrExpressionBody +FILE /elvis.kt + PROPERTY public val p: kotlin.Any? = null getter=null setter=null + EXPRESSION_BODY CONST Null type=kotlin.Nothing? value='null' - IrFunction public fun foo(): kotlin.Any? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Null type=kotlin.Nothing? value='null' - IrFunction public fun test1(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any): kotlin.Any - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - BLOCK type=kotlin.Any hasResult=true operator=ELVIS - WHEN type=kotlin.Any operator=null - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR a type=kotlin.Any? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: GET_VAR b type=kotlin.Any operator=null - else: GET_VAR a type=kotlin.Any? operator=null - IrFunction public fun test2(/*0*/ a: kotlin.String?, /*1*/ b: kotlin.Any): kotlin.Any - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - BLOCK type=kotlin.Any hasResult=true operator=ELVIS - WHEN type=kotlin.Any operator=null - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR a type=kotlin.String? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: GET_VAR b type=kotlin.Any operator=null - else: GET_VAR a type=kotlin.String? operator=null - IrFunction public fun test3(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any?): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR b type=kotlin.Any? operator=null - then: RETURN type= - CONST String type=kotlin.String value='' - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String? - GET_VAR a type=kotlin.Any? operator=null - then: RETURN type= - CONST String type=kotlin.String value='' - RETURN type= - BLOCK type=kotlin.String hasResult=true operator=ELVIS - WHEN type=kotlin.String operator=null - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR a type=kotlin.Any? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String - GET_VAR b type=kotlin.Any? operator=null - else: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String - GET_VAR a type=kotlin.Any? operator=null - IrFunction public fun test4(/*0*/ x: kotlin.Any): kotlin.Any - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - BLOCK type=kotlin.Any hasResult=true operator=ELVIS - VAR val tmp0_elvis_lhs: kotlin.Any? - CALL . type=kotlin.Any? operator=GET_PROPERTY - WHEN type=kotlin.Any operator=null - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp0_elvis_lhs type=kotlin.Any? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: GET_VAR x type=kotlin.Any operator=null - else: GET_VAR tmp0_elvis_lhs type=kotlin.Any? operator=null - IrFunction public fun test5(/*0*/ x: kotlin.Any): kotlin.Any - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - BLOCK type=kotlin.Any hasResult=true operator=ELVIS - VAR val tmp0_elvis_lhs: kotlin.Any? - CALL .foo type=kotlin.Any? operator=null - WHEN type=kotlin.Any operator=null - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp0_elvis_lhs type=kotlin.Any? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: GET_VAR x type=kotlin.Any operator=null - else: GET_VAR tmp0_elvis_lhs type=kotlin.Any? operator=null + FUN public fun foo(): kotlin.Any? + BLOCK_BODY + RETURN type= + CONST Null type=kotlin.Nothing? value='null' + FUN public fun test1(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any): kotlin.Any + BLOCK_BODY + RETURN type= + BLOCK type=kotlin.Any operator=ELVIS + WHEN type=kotlin.Any operator=null + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR a type=kotlin.Any? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: GET_VAR b type=kotlin.Any operator=null + else: GET_VAR a type=kotlin.Any? operator=null + FUN public fun test2(/*0*/ a: kotlin.String?, /*1*/ b: kotlin.Any): kotlin.Any + BLOCK_BODY + RETURN type= + BLOCK type=kotlin.Any operator=ELVIS + WHEN type=kotlin.Any operator=null + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR a type=kotlin.String? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: GET_VAR b type=kotlin.Any operator=null + else: GET_VAR a type=kotlin.String? operator=null + FUN public fun test3(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any?): kotlin.String + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR b type=kotlin.Any? operator=null + then: RETURN type= + CONST String type=kotlin.String value='' + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String? + GET_VAR a type=kotlin.Any? operator=null + then: RETURN type= + CONST String type=kotlin.String value='' + RETURN type= + BLOCK type=kotlin.String operator=ELVIS + WHEN type=kotlin.String operator=null + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR a type=kotlin.Any? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR b type=kotlin.Any? operator=null + else: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR a type=kotlin.Any? operator=null + FUN public fun test4(/*0*/ x: kotlin.Any): kotlin.Any + BLOCK_BODY + RETURN type= + BLOCK type=kotlin.Any operator=ELVIS + VAR val tmp0_elvis_lhs: kotlin.Any? + CALL . type=kotlin.Any? operator=GET_PROPERTY + WHEN type=kotlin.Any operator=null + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR tmp0_elvis_lhs type=kotlin.Any? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: GET_VAR x type=kotlin.Any operator=null + else: GET_VAR tmp0_elvis_lhs type=kotlin.Any? operator=null + FUN public fun test5(/*0*/ x: kotlin.Any): kotlin.Any + BLOCK_BODY + RETURN type= + BLOCK type=kotlin.Any operator=ELVIS + VAR val tmp0_elvis_lhs: kotlin.Any? + CALL .foo type=kotlin.Any? operator=null + WHEN type=kotlin.Any operator=null + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR tmp0_elvis_lhs type=kotlin.Any? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: GET_VAR x type=kotlin.Any operator=null + else: GET_VAR tmp0_elvis_lhs type=kotlin.Any? operator=null diff --git a/compiler/testData/ir/irText/equality.txt b/compiler/testData/ir/irText/equality.txt index ad40677b58a..e17e869b8bd 100644 --- a/compiler/testData/ir/irText/equality.txt +++ b/compiler/testData/ir/irText/equality.txt @@ -1,23 +1,20 @@ -IrFile /equality.kt - IrFunction public fun test1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .EQEQ type=kotlin.Boolean operator=EQEQ +FILE /equality.kt + FUN public fun test1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR a type=kotlin.Int operator=null + arg1: GET_VAR b type=kotlin.Int operator=null + FUN public fun test2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .NOT type=kotlin.Boolean operator=EXCLEQ + arg0: CALL .EQEQ type=kotlin.Boolean operator=EXCLEQ arg0: GET_VAR a type=kotlin.Int operator=null arg1: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .NOT type=kotlin.Boolean operator=EXCLEQ - arg0: CALL .EQEQ type=kotlin.Boolean operator=EXCLEQ - arg0: GET_VAR a type=kotlin.Int operator=null - arg1: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test3(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any?): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR a type=kotlin.Any? operator=null - arg1: GET_VAR b type=kotlin.Any? operator=null + FUN public fun test3(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any?): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR a type=kotlin.Any? operator=null + arg1: GET_VAR b type=kotlin.Any? operator=null diff --git a/compiler/testData/ir/irText/extensionPropertyGetterCall.txt b/compiler/testData/ir/irText/extensionPropertyGetterCall.txt index 18d3a8bf0f5..580673c9a67 100644 --- a/compiler/testData/ir/irText/extensionPropertyGetterCall.txt +++ b/compiler/testData/ir/irText/extensionPropertyGetterCall.txt @@ -1,13 +1,11 @@ -IrFile /extensionPropertyGetterCall.kt - IrProperty public val kotlin.String.okext: kotlin.String getter= setter=null - IrPropertyGetter public fun kotlin.String.(): kotlin.String property=okext - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST String type=kotlin.String value='OK' - IrFunction public fun kotlin.String.test5(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL . type=kotlin.String operator=GET_PROPERTY - $receiver: $RECEIVER of: test5 type=kotlin.String +FILE /extensionPropertyGetterCall.kt + PROPERTY public val kotlin.String.okext: kotlin.String getter= setter=null + PROPERTY_GETTER public fun kotlin.String.(): kotlin.String property=okext + BLOCK_BODY + RETURN type= + CONST String type=kotlin.String value='OK' + FUN public fun kotlin.String.test5(): kotlin.String + BLOCK_BODY + RETURN type= + CALL . type=kotlin.String operator=GET_PROPERTY + $receiver: $RECEIVER of: test5 type=kotlin.String diff --git a/compiler/testData/ir/irText/for.txt b/compiler/testData/ir/irText/for.txt index a71fd82df28..4c7275023b9 100644 --- a/compiler/testData/ir/irText/for.txt +++ b/compiler/testData/ir/irText/for.txt @@ -1,43 +1,41 @@ -IrFile /for.kt - IrFunction public fun testIterable(/*0*/ ss: kotlin.collections.List): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp0_iterator: kotlin.collections.Iterator - CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR - $this: GET_VAR ss type=kotlin.collections.List operator=null - WHILE label=null operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val s: kotlin.String - CALL .next type=kotlin.String operator=FOR_LOOP_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - BLOCK type= hasResult=false operator=null - CALL .println type=kotlin.Unit operator=null - message: GET_VAR s type=kotlin.String operator=null - IrFunction public fun testDestructuring(/*0*/ pp: kotlin.collections.List>): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp0_iterator: kotlin.collections.Iterator> - CALL .iterator type=kotlin.collections.Iterator> operator=FOR_LOOP_ITERATOR - $this: GET_VAR pp type=kotlin.collections.List> operator=null - WHILE label=null operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator> operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val tmp1_loop_parameter: kotlin.Pair - CALL .next type=kotlin.Pair operator=FOR_LOOP_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator> operator=null - VAR val i: kotlin.Int - CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1) - $this: GET_VAR tmp1_loop_parameter type=kotlin.Pair operator=null - VAR val s: kotlin.String - CALL .component2 type=kotlin.String operator=COMPONENT_N(index=2) - $this: GET_VAR tmp1_loop_parameter type=kotlin.Pair operator=null - BLOCK type= hasResult=false operator=null - CALL .println type=kotlin.Unit operator=null - message: GET_VAR i type=kotlin.Int operator=null - CALL .println type=kotlin.Unit operator=null - message: GET_VAR s type=kotlin.String operator=null +FILE /for.kt + FUN public fun testIterable(/*0*/ ss: kotlin.collections.List): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp0_iterator: kotlin.collections.Iterator + CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR + $this: GET_VAR ss type=kotlin.collections.List operator=null + WHILE label=null operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val s: kotlin.String + CALL .next type=kotlin.String operator=FOR_LOOP_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + BLOCK type=kotlin.Unit operator=null + CALL .println type=kotlin.Unit operator=null + message: GET_VAR s type=kotlin.String operator=null + FUN public fun testDestructuring(/*0*/ pp: kotlin.collections.List>): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp0_iterator: kotlin.collections.Iterator> + CALL .iterator type=kotlin.collections.Iterator> operator=FOR_LOOP_ITERATOR + $this: GET_VAR pp type=kotlin.collections.List> operator=null + WHILE label=null operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator> operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val tmp1_loop_parameter: kotlin.Pair + CALL .next type=kotlin.Pair operator=FOR_LOOP_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator> operator=null + VAR val i: kotlin.Int + CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1) + $this: GET_VAR tmp1_loop_parameter type=kotlin.Pair operator=null + VAR val s: kotlin.String + CALL .component2 type=kotlin.String operator=COMPONENT_N(index=2) + $this: GET_VAR tmp1_loop_parameter type=kotlin.Pair operator=null + BLOCK type=kotlin.Unit operator=null + CALL .println type=kotlin.Unit operator=null + message: GET_VAR i type=kotlin.Int operator=null + CALL .println type=kotlin.Unit operator=null + message: GET_VAR s type=kotlin.String operator=null diff --git a/compiler/testData/ir/irText/forWithBreakContinue.txt b/compiler/testData/ir/irText/forWithBreakContinue.txt index 3d7545bf96c..e4d79b5d963 100644 --- a/compiler/testData/ir/irText/forWithBreakContinue.txt +++ b/compiler/testData/ir/irText/forWithBreakContinue.txt @@ -1,95 +1,91 @@ -IrFile /forWithBreakContinue.kt - IrFunction public fun testForBreak1(/*0*/ ss: kotlin.collections.List): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp0_iterator: kotlin.collections.Iterator - CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR - $this: GET_VAR ss type=kotlin.collections.List operator=null - WHILE label=null operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val s: kotlin.String - CALL .next type=kotlin.String operator=FOR_LOOP_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - BLOCK type= hasResult=false operator=null - BREAK label=null depth=0 - IrFunction public fun testForBreak2(/*0*/ ss: kotlin.collections.List): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp0_iterator: kotlin.collections.Iterator - CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR - $this: GET_VAR ss type=kotlin.collections.List operator=null - WHILE label=OUTER operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val s1: kotlin.String - CALL .next type=kotlin.String operator=FOR_LOOP_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp1_iterator: kotlin.collections.Iterator - CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR - $this: GET_VAR ss type=kotlin.collections.List operator=null - WHILE label=INNER operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val s2: kotlin.String - CALL .next type=kotlin.String operator=FOR_LOOP_NEXT - $this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator operator=null - BLOCK type= hasResult=false operator=null - BREAK label=OUTER depth=1 - BREAK label=INNER depth=0 - BREAK label=null depth=0 - BREAK label=OUTER depth=0 - IrFunction public fun testForContinue1(/*0*/ ss: kotlin.collections.List): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp0_iterator: kotlin.collections.Iterator - CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR - $this: GET_VAR ss type=kotlin.collections.List operator=null - WHILE label=null operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val s: kotlin.String - CALL .next type=kotlin.String operator=FOR_LOOP_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - BLOCK type= hasResult=false operator=null - CONTINUE label=null depth=0 - IrFunction public fun testForContinue2(/*0*/ ss: kotlin.collections.List): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp0_iterator: kotlin.collections.Iterator - CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR - $this: GET_VAR ss type=kotlin.collections.List operator=null - WHILE label=OUTER operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val s1: kotlin.String - CALL .next type=kotlin.String operator=FOR_LOOP_NEXT - $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp1_iterator: kotlin.collections.Iterator - CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR - $this: GET_VAR ss type=kotlin.collections.List operator=null - WHILE label=INNER operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val s2: kotlin.String - CALL .next type=kotlin.String operator=FOR_LOOP_NEXT - $this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator operator=null - BLOCK type= hasResult=false operator=null - CONTINUE label=OUTER depth=1 - CONTINUE label=INNER depth=0 - CONTINUE label=null depth=0 - CONTINUE label=OUTER depth=0 +FILE /forWithBreakContinue.kt + FUN public fun testForBreak1(/*0*/ ss: kotlin.collections.List): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp0_iterator: kotlin.collections.Iterator + CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR + $this: GET_VAR ss type=kotlin.collections.List operator=null + WHILE label=null operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val s: kotlin.String + CALL .next type=kotlin.String operator=FOR_LOOP_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + BLOCK type=kotlin.Nothing operator=null + BREAK label=null depth=0 + FUN public fun testForBreak2(/*0*/ ss: kotlin.collections.List): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp0_iterator: kotlin.collections.Iterator + CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR + $this: GET_VAR ss type=kotlin.collections.List operator=null + WHILE label=OUTER operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val s1: kotlin.String + CALL .next type=kotlin.String operator=FOR_LOOP_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + BLOCK type=kotlin.Nothing operator=null + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp1_iterator: kotlin.collections.Iterator + CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR + $this: GET_VAR ss type=kotlin.collections.List operator=null + WHILE label=INNER operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val s2: kotlin.String + CALL .next type=kotlin.String operator=FOR_LOOP_NEXT + $this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator operator=null + BLOCK type=kotlin.Nothing operator=null + BREAK label=OUTER depth=1 + BREAK label=INNER depth=0 + BREAK label=null depth=0 + BREAK label=OUTER depth=0 + FUN public fun testForContinue1(/*0*/ ss: kotlin.collections.List): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp0_iterator: kotlin.collections.Iterator + CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR + $this: GET_VAR ss type=kotlin.collections.List operator=null + WHILE label=null operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val s: kotlin.String + CALL .next type=kotlin.String operator=FOR_LOOP_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + BLOCK type=kotlin.Nothing operator=null + CONTINUE label=null depth=0 + FUN public fun testForContinue2(/*0*/ ss: kotlin.collections.List): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp0_iterator: kotlin.collections.Iterator + CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR + $this: GET_VAR ss type=kotlin.collections.List operator=null + WHILE label=OUTER operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val s1: kotlin.String + CALL .next type=kotlin.String operator=FOR_LOOP_NEXT + $this: GET_VAR tmp0_iterator type=kotlin.collections.Iterator operator=null + BLOCK type=kotlin.Nothing operator=null + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp1_iterator: kotlin.collections.Iterator + CALL .iterator type=kotlin.collections.Iterator operator=FOR_LOOP_ITERATOR + $this: GET_VAR ss type=kotlin.collections.List operator=null + WHILE label=INNER operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val s2: kotlin.String + CALL .next type=kotlin.String operator=FOR_LOOP_NEXT + $this: GET_VAR tmp1_iterator type=kotlin.collections.Iterator operator=null + BLOCK type=kotlin.Nothing operator=null + CONTINUE label=OUTER depth=1 + CONTINUE label=INNER depth=0 + CONTINUE label=null depth=0 + CONTINUE label=OUTER depth=0 diff --git a/compiler/testData/ir/irText/forWithImplicitReceivers.txt b/compiler/testData/ir/irText/forWithImplicitReceivers.txt index 8c0024b872a..a067cfc35aa 100644 --- a/compiler/testData/ir/irText/forWithImplicitReceivers.txt +++ b/compiler/testData/ir/irText/forWithImplicitReceivers.txt @@ -1,24 +1,23 @@ -IrFile /forWithImplicitReceivers.kt +FILE /forWithImplicitReceivers.kt DUMMY FiveTimes DUMMY IntCell DUMMY IReceiver - IrFunction public fun IReceiver.test(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP - VAR val tmp0_iterator: IntCell - CALL .iterator type=IntCell operator=FOR_LOOP_ITERATOR - $this: $RECEIVER of: test type=IReceiver - $receiver: GET_OBJECT FiveTimes type=FiveTimes - WHILE label=null operator=FOR_LOOP_INNER_WHILE - condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT - $this: $RECEIVER of: test type=IReceiver - $receiver: GET_VAR tmp0_iterator type=IntCell operator=null - body: BLOCK type=kotlin.Unit hasResult=false operator=FOR_LOOP_INNER_WHILE - VAR val i: kotlin.Int - CALL .next type=kotlin.Int operator=FOR_LOOP_NEXT - $this: $RECEIVER of: test type=IReceiver - $receiver: GET_VAR tmp0_iterator type=IntCell operator=null - BLOCK type= hasResult=false operator=null - CALL .println type=kotlin.Unit operator=null - message: GET_VAR i type=kotlin.Int operator=null + FUN public fun IReceiver.test(): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Unit operator=FOR_LOOP + VAR val tmp0_iterator: IntCell + CALL .iterator type=IntCell operator=FOR_LOOP_ITERATOR + $this: $RECEIVER of: test type=IReceiver + $receiver: GET_OBJECT FiveTimes type=FiveTimes + WHILE label=null operator=FOR_LOOP_INNER_WHILE + condition: CALL .hasNext type=kotlin.Boolean operator=FOR_LOOP_HAS_NEXT + $this: $RECEIVER of: test type=IReceiver + $receiver: GET_VAR tmp0_iterator type=IntCell operator=null + body: BLOCK type=kotlin.Unit operator=FOR_LOOP_INNER_WHILE + VAR val i: kotlin.Int + CALL .next type=kotlin.Int operator=FOR_LOOP_NEXT + $this: $RECEIVER of: test type=IReceiver + $receiver: GET_VAR tmp0_iterator type=IntCell operator=null + BLOCK type=kotlin.Unit operator=null + CALL .println type=kotlin.Unit operator=null + message: GET_VAR i type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/identity.txt b/compiler/testData/ir/irText/identity.txt index 022828aeb81..26fffd1dba9 100644 --- a/compiler/testData/ir/irText/identity.txt +++ b/compiler/testData/ir/irText/identity.txt @@ -1,23 +1,20 @@ -IrFile /identity.kt - IrFunction public fun test1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .EQEQEQ type=kotlin.Boolean operator=EQEQEQ +FILE /identity.kt + FUN public fun test1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .EQEQEQ type=kotlin.Boolean operator=EQEQEQ + arg0: GET_VAR a type=kotlin.Int operator=null + arg1: GET_VAR b type=kotlin.Int operator=null + FUN public fun test2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .NOT type=kotlin.Boolean operator=EXCLEQEQ + arg0: CALL .EQEQEQ type=kotlin.Boolean operator=EXCLEQEQ arg0: GET_VAR a type=kotlin.Int operator=null arg1: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .NOT type=kotlin.Boolean operator=EXCLEQEQ - arg0: CALL .EQEQEQ type=kotlin.Boolean operator=EXCLEQEQ - arg0: GET_VAR a type=kotlin.Int operator=null - arg1: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test3(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any?): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .EQEQEQ type=kotlin.Boolean operator=EQEQEQ - arg0: GET_VAR a type=kotlin.Any? operator=null - arg1: GET_VAR b type=kotlin.Any? operator=null + FUN public fun test3(/*0*/ a: kotlin.Any?, /*1*/ b: kotlin.Any?): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .EQEQEQ type=kotlin.Boolean operator=EQEQEQ + arg0: GET_VAR a type=kotlin.Any? operator=null + arg1: GET_VAR b type=kotlin.Any? operator=null diff --git a/compiler/testData/ir/irText/ifElseIf.txt b/compiler/testData/ir/irText/ifElseIf.txt index 22f319172a5..7f0b1c6765c 100644 --- a/compiler/testData/ir/irText/ifElseIf.txt +++ b/compiler/testData/ir/irText/ifElseIf.txt @@ -1,18 +1,17 @@ -IrFile /ifElseIf.kt - IrFunction public fun test(/*0*/ i: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Int operator=WHEN - if: CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: GET_VAR i type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='0' - then: CONST Int type=kotlin.Int value='1' - if: CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR i type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='0' - then: CALL .unaryMinus type=kotlin.Int operator=UMINUS - $this: CONST Int type=kotlin.Int value='1' - else: CONST Int type=kotlin.Int value='0' +FILE /ifElseIf.kt + FUN public fun test(/*0*/ i: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + WHEN type=kotlin.Int operator=WHEN + if: CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: GET_VAR i type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='0' + then: CONST Int type=kotlin.Int value='1' + if: CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR i type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='0' + then: CALL .unaryMinus type=kotlin.Int operator=UMINUS + $this: CONST Int type=kotlin.Int value='1' + else: CONST Int type=kotlin.Int value='0' diff --git a/compiler/testData/ir/irText/implicitCastOnPlatformType.txt b/compiler/testData/ir/irText/implicitCastOnPlatformType.txt index f67d1dcfadd..3c9a73994f7 100644 --- a/compiler/testData/ir/irText/implicitCastOnPlatformType.txt +++ b/compiler/testData/ir/irText/implicitCastOnPlatformType.txt @@ -1,8 +1,7 @@ -IrFile /implicitCastOnPlatformType.kt - IrFunction public fun test(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=kotlin.String - CALL .getProperty type=kotlin.String! operator=null - p0: CONST String type=kotlin.String value='test' +FILE /implicitCastOnPlatformType.kt + FUN public fun test(): kotlin.String + BLOCK_BODY + RETURN type= + TYPE_OP operator=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL .getProperty type=kotlin.String! operator=null + p0: CONST String type=kotlin.String value='test' diff --git a/compiler/testData/ir/irText/in.txt b/compiler/testData/ir/irText/in.txt index 877f6743c73..6fc14a362f3 100644 --- a/compiler/testData/ir/irText/in.txt +++ b/compiler/testData/ir/irText/in.txt @@ -1,31 +1,27 @@ -IrFile /in.kt - IrFunction public fun test1(/*0*/ a: kotlin.Any, /*1*/ x: kotlin.collections.Collection): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .contains type=kotlin.Boolean operator=IN +FILE /in.kt + FUN public fun test1(/*0*/ a: kotlin.Any, /*1*/ x: kotlin.collections.Collection): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .contains type=kotlin.Boolean operator=IN + $this: GET_VAR x type=kotlin.collections.Collection operator=null + element: GET_VAR a type=kotlin.Any operator=null + FUN public fun test2(/*0*/ a: kotlin.Any, /*1*/ x: kotlin.collections.Collection): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .NOT type=kotlin.Boolean operator=NOT_IN + arg0: CALL .contains type=kotlin.Boolean operator=NOT_IN $this: GET_VAR x type=kotlin.collections.Collection operator=null element: GET_VAR a type=kotlin.Any operator=null - IrFunction public fun test2(/*0*/ a: kotlin.Any, /*1*/ x: kotlin.collections.Collection): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .NOT type=kotlin.Boolean operator=NOT_IN - arg0: CALL .contains type=kotlin.Boolean operator=NOT_IN - $this: GET_VAR x type=kotlin.collections.Collection operator=null - element: GET_VAR a type=kotlin.Any operator=null - IrFunction public fun test3(/*0*/ a: T, /*1*/ x: kotlin.collections.Collection): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .contains type=kotlin.Boolean operator=IN + FUN public fun test3(/*0*/ a: T, /*1*/ x: kotlin.collections.Collection): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .contains type=kotlin.Boolean operator=IN + $this: GET_VAR x type=kotlin.collections.Collection operator=null + element: GET_VAR a type=T operator=null + FUN public fun test4(/*0*/ a: T, /*1*/ x: kotlin.collections.Collection): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .NOT type=kotlin.Boolean operator=NOT_IN + arg0: CALL .contains type=kotlin.Boolean operator=NOT_IN $this: GET_VAR x type=kotlin.collections.Collection operator=null element: GET_VAR a type=T operator=null - IrFunction public fun test4(/*0*/ a: T, /*1*/ x: kotlin.collections.Collection): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .NOT type=kotlin.Boolean operator=NOT_IN - arg0: CALL .contains type=kotlin.Boolean operator=NOT_IN - $this: GET_VAR x type=kotlin.collections.Collection operator=null - element: GET_VAR a type=T operator=null diff --git a/compiler/testData/ir/irText/incrementDecrement.txt b/compiler/testData/ir/irText/incrementDecrement.txt index 05d70b579b9..696eeed143d 100644 --- a/compiler/testData/ir/irText/incrementDecrement.txt +++ b/compiler/testData/ir/irText/incrementDecrement.txt @@ -1,151 +1,145 @@ -IrFile /incrementDecrement.kt - IrProperty public var p: kotlin.Int getter=null setter=null - IrExpressionBody +FILE /incrementDecrement.kt + PROPERTY public var p: kotlin.Int getter=null setter=null + EXPRESSION_BODY CONST Int type=kotlin.Int value='0' - IrProperty public val arr: kotlin.IntArray getter=null setter=null - IrExpressionBody + PROPERTY public val arr: kotlin.IntArray getter=null setter=null + EXPRESSION_BODY CALL .intArrayOf type=kotlin.IntArray operator=null elements: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.IntArray DUMMY vararg type=kotlin.Int - IrFunction public fun testVarPrefix(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR var x: kotlin.Int - CONST Int type=kotlin.Int value='0' - VAR val x1: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=PREFIX_INCR - VAR val tmp0: kotlin.Int - CALL .inc type=kotlin.Int operator=PREFIX_INCR - $this: GET_VAR x type=kotlin.Int operator=PREFIX_INCR - SET_VAR x type= operator=PREFIX_INCR - GET_VAR tmp0 type=kotlin.Int operator=null + FUN public fun testVarPrefix(): kotlin.Unit + BLOCK_BODY + VAR var x: kotlin.Int + CONST Int type=kotlin.Int value='0' + VAR val x1: kotlin.Int + BLOCK type=kotlin.Int operator=PREFIX_INCR + VAR val tmp0: kotlin.Int + CALL .inc type=kotlin.Int operator=PREFIX_INCR + $this: GET_VAR x type=kotlin.Int operator=PREFIX_INCR + SET_VAR x type= operator=PREFIX_INCR GET_VAR tmp0 type=kotlin.Int operator=null - VAR val x2: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=PREFIX_DECR - VAR val tmp1: kotlin.Int - CALL .dec type=kotlin.Int operator=PREFIX_DECR - $this: GET_VAR x type=kotlin.Int operator=PREFIX_DECR - SET_VAR x type= operator=PREFIX_DECR - GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp0 type=kotlin.Int operator=null + VAR val x2: kotlin.Int + BLOCK type=kotlin.Int operator=PREFIX_DECR + VAR val tmp1: kotlin.Int + CALL .dec type=kotlin.Int operator=PREFIX_DECR + $this: GET_VAR x type=kotlin.Int operator=PREFIX_DECR + SET_VAR x type= operator=PREFIX_DECR GET_VAR tmp1 type=kotlin.Int operator=null - IrFunction public fun testVarPostfix(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR var x: kotlin.Int - CONST Int type=kotlin.Int value='0' - VAR val x1: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp0: kotlin.Int - GET_VAR x type=kotlin.Int operator=POSTFIX_INCR - SET_VAR x type= operator=POSTFIX_INCR - CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp0 type=kotlin.Int operator=null - GET_VAR tmp0 type=kotlin.Int operator=null - VAR val x2: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_DECR - VAR val tmp1: kotlin.Int - GET_VAR x type=kotlin.Int operator=POSTFIX_DECR - SET_VAR x type= operator=POSTFIX_DECR - CALL .dec type=kotlin.Int operator=POSTFIX_DECR - $this: GET_VAR tmp1 type=kotlin.Int operator=null - GET_VAR tmp1 type=kotlin.Int operator=null - IrFunction public fun testPropPrefix(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR val p1: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=PREFIX_INCR - VAR val tmp0: kotlin.Int - CALL .inc type=kotlin.Int operator=PREFIX_INCR - $this: CALL . type=kotlin.Int operator=PREFIX_INCR - CALL . type=kotlin.Unit operator=PREFIX_INCR - : GET_VAR tmp0 type=kotlin.Int operator=null - GET_VAR tmp0 type=kotlin.Int operator=null - VAR val p2: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=PREFIX_DECR - VAR val tmp1: kotlin.Int - CALL .dec type=kotlin.Int operator=PREFIX_DECR - $this: CALL . type=kotlin.Int operator=PREFIX_DECR - CALL . type=kotlin.Unit operator=PREFIX_DECR - : GET_VAR tmp1 type=kotlin.Int operator=null - GET_VAR tmp1 type=kotlin.Int operator=null - IrFunction public fun testPropPostfix(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR val p1: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp0: kotlin.Int - CALL . type=kotlin.Int operator=POSTFIX_INCR - CALL . type=kotlin.Unit operator=POSTFIX_INCR - : CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp0 type=kotlin.Int operator=null - GET_VAR tmp0 type=kotlin.Int operator=null - VAR val p2: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=PREFIX_DECR - VAR val tmp1: kotlin.Int - CALL .dec type=kotlin.Int operator=PREFIX_DECR - $this: CALL . type=kotlin.Int operator=PREFIX_DECR - CALL . type=kotlin.Unit operator=PREFIX_DECR - : GET_VAR tmp1 type=kotlin.Int operator=null - GET_VAR tmp1 type=kotlin.Int operator=null - IrFunction public fun testArrayPrefix(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR val a1: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=PREFIX_INCR - VAR val tmp0_array: kotlin.IntArray - CALL . type=kotlin.IntArray operator=GET_PROPERTY - VAR val tmp1: kotlin.Int - CALL .inc type=kotlin.Int operator=PREFIX_INCR - $this: CALL .get type=kotlin.Int operator=PREFIX_INCR - $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='0' - CALL .set type=kotlin.Unit operator=PREFIX_INCR - $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='0' - value: GET_VAR tmp1 type=kotlin.Int operator=null - GET_VAR tmp1 type=kotlin.Int operator=null - VAR val a2: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=PREFIX_DECR - VAR val tmp2_array: kotlin.IntArray - CALL . type=kotlin.IntArray operator=GET_PROPERTY - VAR val tmp3: kotlin.Int - CALL .dec type=kotlin.Int operator=PREFIX_DECR - $this: CALL .get type=kotlin.Int operator=PREFIX_DECR - $this: GET_VAR tmp2_array type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='0' - CALL .set type=kotlin.Unit operator=PREFIX_DECR - $this: GET_VAR tmp2_array type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='0' - value: GET_VAR tmp3 type=kotlin.Int operator=null - GET_VAR tmp3 type=kotlin.Int operator=null - IrFunction public fun testArrayPostfix(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR val a1: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp0_array: kotlin.IntArray - CALL . type=kotlin.IntArray operator=GET_PROPERTY - VAR val tmp1: kotlin.Int - CALL .get type=kotlin.Int operator=POSTFIX_INCR + GET_VAR tmp1 type=kotlin.Int operator=null + FUN public fun testVarPostfix(): kotlin.Unit + BLOCK_BODY + VAR var x: kotlin.Int + CONST Int type=kotlin.Int value='0' + VAR val x1: kotlin.Int + BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp0: kotlin.Int + GET_VAR x type=kotlin.Int operator=POSTFIX_INCR + SET_VAR x type= operator=POSTFIX_INCR + CALL .inc type=kotlin.Int operator=POSTFIX_INCR + $this: GET_VAR tmp0 type=kotlin.Int operator=null + GET_VAR tmp0 type=kotlin.Int operator=null + VAR val x2: kotlin.Int + BLOCK type=kotlin.Int operator=POSTFIX_DECR + VAR val tmp1: kotlin.Int + GET_VAR x type=kotlin.Int operator=POSTFIX_DECR + SET_VAR x type= operator=POSTFIX_DECR + CALL .dec type=kotlin.Int operator=POSTFIX_DECR + $this: GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp1 type=kotlin.Int operator=null + FUN public fun testPropPrefix(): kotlin.Unit + BLOCK_BODY + VAR val p1: kotlin.Int + BLOCK type=kotlin.Int operator=PREFIX_INCR + VAR val tmp0: kotlin.Int + CALL .inc type=kotlin.Int operator=PREFIX_INCR + $this: CALL . type=kotlin.Int operator=PREFIX_INCR + CALL . type=kotlin.Unit operator=PREFIX_INCR + : GET_VAR tmp0 type=kotlin.Int operator=null + GET_VAR tmp0 type=kotlin.Int operator=null + VAR val p2: kotlin.Int + BLOCK type=kotlin.Int operator=PREFIX_DECR + VAR val tmp1: kotlin.Int + CALL .dec type=kotlin.Int operator=PREFIX_DECR + $this: CALL . type=kotlin.Int operator=PREFIX_DECR + CALL . type=kotlin.Unit operator=PREFIX_DECR + : GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp1 type=kotlin.Int operator=null + FUN public fun testPropPostfix(): kotlin.Unit + BLOCK_BODY + VAR val p1: kotlin.Int + BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp0: kotlin.Int + CALL . type=kotlin.Int operator=POSTFIX_INCR + CALL . type=kotlin.Unit operator=POSTFIX_INCR + : CALL .inc type=kotlin.Int operator=POSTFIX_INCR + $this: GET_VAR tmp0 type=kotlin.Int operator=null + GET_VAR tmp0 type=kotlin.Int operator=null + VAR val p2: kotlin.Int + BLOCK type=kotlin.Int operator=PREFIX_DECR + VAR val tmp1: kotlin.Int + CALL .dec type=kotlin.Int operator=PREFIX_DECR + $this: CALL . type=kotlin.Int operator=PREFIX_DECR + CALL . type=kotlin.Unit operator=PREFIX_DECR + : GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp1 type=kotlin.Int operator=null + FUN public fun testArrayPrefix(): kotlin.Unit + BLOCK_BODY + VAR val a1: kotlin.Int + BLOCK type=kotlin.Int operator=PREFIX_INCR + VAR val tmp0_array: kotlin.IntArray + CALL . type=kotlin.IntArray operator=GET_PROPERTY + VAR val tmp1: kotlin.Int + CALL .inc type=kotlin.Int operator=PREFIX_INCR + $this: CALL .get type=kotlin.Int operator=PREFIX_INCR $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null index: CONST Int type=kotlin.Int value='0' - CALL .set type=kotlin.Unit operator=POSTFIX_INCR - $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null - index: CONST Int type=kotlin.Int value='0' - value: CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp1 type=kotlin.Int operator=null - GET_VAR tmp1 type=kotlin.Int operator=null - VAR val a2: kotlin.Int - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_DECR - VAR val tmp2_array: kotlin.IntArray - CALL . type=kotlin.IntArray operator=GET_PROPERTY - VAR val tmp3: kotlin.Int - CALL .get type=kotlin.Int operator=POSTFIX_DECR + CALL .set type=kotlin.Unit operator=PREFIX_INCR + $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='0' + value: GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp1 type=kotlin.Int operator=null + VAR val a2: kotlin.Int + BLOCK type=kotlin.Int operator=PREFIX_DECR + VAR val tmp2_array: kotlin.IntArray + CALL . type=kotlin.IntArray operator=GET_PROPERTY + VAR val tmp3: kotlin.Int + CALL .dec type=kotlin.Int operator=PREFIX_DECR + $this: CALL .get type=kotlin.Int operator=PREFIX_DECR $this: GET_VAR tmp2_array type=kotlin.IntArray operator=null index: CONST Int type=kotlin.Int value='0' - CALL .set type=kotlin.Unit operator=POSTFIX_DECR + CALL .set type=kotlin.Unit operator=PREFIX_DECR + $this: GET_VAR tmp2_array type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='0' + value: GET_VAR tmp3 type=kotlin.Int operator=null + GET_VAR tmp3 type=kotlin.Int operator=null + FUN public fun testArrayPostfix(): kotlin.Unit + BLOCK_BODY + VAR val a1: kotlin.Int + BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp0_array: kotlin.IntArray + CALL . type=kotlin.IntArray operator=GET_PROPERTY + VAR val tmp1: kotlin.Int + CALL .get type=kotlin.Int operator=POSTFIX_INCR + $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='0' + CALL .set type=kotlin.Unit operator=POSTFIX_INCR + $this: GET_VAR tmp0_array type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='0' + value: CALL .inc type=kotlin.Int operator=POSTFIX_INCR + $this: GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp1 type=kotlin.Int operator=null + VAR val a2: kotlin.Int + BLOCK type=kotlin.Int operator=POSTFIX_DECR + VAR val tmp2_array: kotlin.IntArray + CALL . type=kotlin.IntArray operator=GET_PROPERTY + VAR val tmp3: kotlin.Int + CALL .get type=kotlin.Int operator=POSTFIX_DECR $this: GET_VAR tmp2_array type=kotlin.IntArray operator=null index: CONST Int type=kotlin.Int value='0' - value: CALL .dec type=kotlin.Int operator=POSTFIX_DECR - $this: GET_VAR tmp3 type=kotlin.Int operator=null - GET_VAR tmp3 type=kotlin.Int operator=null + CALL .set type=kotlin.Unit operator=POSTFIX_DECR + $this: GET_VAR tmp2_array type=kotlin.IntArray operator=null + index: CONST Int type=kotlin.Int value='0' + value: CALL .dec type=kotlin.Int operator=POSTFIX_DECR + $this: GET_VAR tmp3 type=kotlin.Int operator=null + GET_VAR tmp3 type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/literals.txt b/compiler/testData/ir/irText/literals.txt index c7fb2cca720..71ceae9b1c5 100644 --- a/compiler/testData/ir/irText/literals.txt +++ b/compiler/testData/ir/irText/literals.txt @@ -1,20 +1,20 @@ -IrFile /literals.kt - IrProperty public val test1: kotlin.Int = 1 getter=null setter=null - IrExpressionBody +FILE /literals.kt + PROPERTY public val test1: kotlin.Int = 1 getter=null setter=null + EXPRESSION_BODY CONST Int type=kotlin.Int value='1' - IrProperty public val test2: kotlin.Int = -1 getter=null setter=null - IrExpressionBody + PROPERTY public val test2: kotlin.Int = -1 getter=null setter=null + EXPRESSION_BODY CALL .unaryMinus type=kotlin.Int operator=UMINUS $this: CONST Int type=kotlin.Int value='1' - IrProperty public val test3: kotlin.Boolean = true getter=null setter=null - IrExpressionBody + PROPERTY public val test3: kotlin.Boolean = true getter=null setter=null + EXPRESSION_BODY CONST Boolean type=kotlin.Boolean value='true' - IrProperty public val test4: kotlin.Boolean = false getter=null setter=null - IrExpressionBody + PROPERTY public val test4: kotlin.Boolean = false getter=null setter=null + EXPRESSION_BODY CONST Boolean type=kotlin.Boolean value='false' - IrProperty public val test5: kotlin.String = "abc" getter=null setter=null - IrExpressionBody + PROPERTY public val test5: kotlin.String = "abc" getter=null setter=null + EXPRESSION_BODY CONST String type=kotlin.String value='abc' - IrProperty public val test6: kotlin.Nothing? = null getter=null setter=null - IrExpressionBody + PROPERTY public val test6: kotlin.Nothing? = null getter=null setter=null + EXPRESSION_BODY CONST Null type=kotlin.Nothing? value='null' diff --git a/compiler/testData/ir/irText/primitiveComparisons.txt b/compiler/testData/ir/irText/primitiveComparisons.txt index f979fecf528..1c517001d80 100644 --- a/compiler/testData/ir/irText/primitiveComparisons.txt +++ b/compiler/testData/ir/irText/primitiveComparisons.txt @@ -1,193 +1,169 @@ -IrFile /primitiveComparisons.kt - IrFunction public fun btest1(/*0*/ a: kotlin.Byte, /*1*/ b: kotlin.Byte): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: GET_VAR a type=kotlin.Byte operator=null - other: GET_VAR b type=kotlin.Byte operator=null - IrFunction public fun btest2(/*0*/ a: kotlin.Byte, /*1*/ b: kotlin.Byte): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR a type=kotlin.Byte operator=null - other: GET_VAR b type=kotlin.Byte operator=null - IrFunction public fun btest3(/*0*/ a: kotlin.Byte, /*1*/ b: kotlin.Byte): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ - arg0: CALL .compareTo type=kotlin.Int operator=GTEQ - $this: GET_VAR a type=kotlin.Byte operator=null - other: GET_VAR b type=kotlin.Byte operator=null - IrFunction public fun btest4(/*0*/ a: kotlin.Byte, /*1*/ b: kotlin.Byte): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ - arg0: CALL .compareTo type=kotlin.Int operator=LTEQ - $this: GET_VAR a type=kotlin.Byte operator=null - other: GET_VAR b type=kotlin.Byte operator=null - IrFunction public fun stest1(/*0*/ a: kotlin.Short, /*1*/ b: kotlin.Short): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: GET_VAR a type=kotlin.Short operator=null - other: GET_VAR b type=kotlin.Short operator=null - IrFunction public fun stest2(/*0*/ a: kotlin.Short, /*1*/ b: kotlin.Short): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR a type=kotlin.Short operator=null - other: GET_VAR b type=kotlin.Short operator=null - IrFunction public fun stest3(/*0*/ a: kotlin.Short, /*1*/ b: kotlin.Short): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ - arg0: CALL .compareTo type=kotlin.Int operator=GTEQ - $this: GET_VAR a type=kotlin.Short operator=null - other: GET_VAR b type=kotlin.Short operator=null - IrFunction public fun stest4(/*0*/ a: kotlin.Short, /*1*/ b: kotlin.Short): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ - arg0: CALL .compareTo type=kotlin.Int operator=LTEQ - $this: GET_VAR a type=kotlin.Short operator=null - other: GET_VAR b type=kotlin.Short operator=null - IrFunction public fun itest1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun itest2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun itest3(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ - arg0: CALL .compareTo type=kotlin.Int operator=GTEQ - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun itest4(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ - arg0: CALL .compareTo type=kotlin.Int operator=LTEQ - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun ltest1(/*0*/ a: kotlin.Long, /*1*/ b: kotlin.Long): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: GET_VAR a type=kotlin.Long operator=null - other: GET_VAR b type=kotlin.Long operator=null - IrFunction public fun ltest2(/*0*/ a: kotlin.Long, /*1*/ b: kotlin.Long): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR a type=kotlin.Long operator=null - other: GET_VAR b type=kotlin.Long operator=null - IrFunction public fun ltest3(/*0*/ a: kotlin.Long, /*1*/ b: kotlin.Long): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ - arg0: CALL .compareTo type=kotlin.Int operator=GTEQ - $this: GET_VAR a type=kotlin.Long operator=null - other: GET_VAR b type=kotlin.Long operator=null - IrFunction public fun ltest4(/*0*/ a: kotlin.Long, /*1*/ b: kotlin.Long): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ - arg0: CALL .compareTo type=kotlin.Int operator=LTEQ - $this: GET_VAR a type=kotlin.Long operator=null - other: GET_VAR b type=kotlin.Long operator=null - IrFunction public fun ftest1(/*0*/ a: kotlin.Float, /*1*/ b: kotlin.Float): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: GET_VAR a type=kotlin.Float operator=null - other: GET_VAR b type=kotlin.Float operator=null - IrFunction public fun ftest2(/*0*/ a: kotlin.Float, /*1*/ b: kotlin.Float): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR a type=kotlin.Float operator=null - other: GET_VAR b type=kotlin.Float operator=null - IrFunction public fun ftest3(/*0*/ a: kotlin.Float, /*1*/ b: kotlin.Float): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ - arg0: CALL .compareTo type=kotlin.Int operator=GTEQ - $this: GET_VAR a type=kotlin.Float operator=null - other: GET_VAR b type=kotlin.Float operator=null - IrFunction public fun ftest4(/*0*/ a: kotlin.Float, /*1*/ b: kotlin.Float): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ - arg0: CALL .compareTo type=kotlin.Int operator=LTEQ - $this: GET_VAR a type=kotlin.Float operator=null - other: GET_VAR b type=kotlin.Float operator=null - IrFunction public fun dtest1(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Double): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: GET_VAR a type=kotlin.Double operator=null - other: GET_VAR b type=kotlin.Double operator=null - IrFunction public fun dtest2(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Double): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR a type=kotlin.Double operator=null - other: GET_VAR b type=kotlin.Double operator=null - IrFunction public fun dtest3(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Double): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ - arg0: CALL .compareTo type=kotlin.Int operator=GTEQ - $this: GET_VAR a type=kotlin.Double operator=null - other: GET_VAR b type=kotlin.Double operator=null - IrFunction public fun dtest4(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Double): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ - arg0: CALL .compareTo type=kotlin.Int operator=LTEQ - $this: GET_VAR a type=kotlin.Double operator=null - other: GET_VAR b type=kotlin.Double operator=null +FILE /primitiveComparisons.kt + FUN public fun btest1(/*0*/ a: kotlin.Byte, /*1*/ b: kotlin.Byte): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: GET_VAR a type=kotlin.Byte operator=null + other: GET_VAR b type=kotlin.Byte operator=null + FUN public fun btest2(/*0*/ a: kotlin.Byte, /*1*/ b: kotlin.Byte): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR a type=kotlin.Byte operator=null + other: GET_VAR b type=kotlin.Byte operator=null + FUN public fun btest3(/*0*/ a: kotlin.Byte, /*1*/ b: kotlin.Byte): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ + arg0: CALL .compareTo type=kotlin.Int operator=GTEQ + $this: GET_VAR a type=kotlin.Byte operator=null + other: GET_VAR b type=kotlin.Byte operator=null + FUN public fun btest4(/*0*/ a: kotlin.Byte, /*1*/ b: kotlin.Byte): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ + arg0: CALL .compareTo type=kotlin.Int operator=LTEQ + $this: GET_VAR a type=kotlin.Byte operator=null + other: GET_VAR b type=kotlin.Byte operator=null + FUN public fun stest1(/*0*/ a: kotlin.Short, /*1*/ b: kotlin.Short): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: GET_VAR a type=kotlin.Short operator=null + other: GET_VAR b type=kotlin.Short operator=null + FUN public fun stest2(/*0*/ a: kotlin.Short, /*1*/ b: kotlin.Short): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR a type=kotlin.Short operator=null + other: GET_VAR b type=kotlin.Short operator=null + FUN public fun stest3(/*0*/ a: kotlin.Short, /*1*/ b: kotlin.Short): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ + arg0: CALL .compareTo type=kotlin.Int operator=GTEQ + $this: GET_VAR a type=kotlin.Short operator=null + other: GET_VAR b type=kotlin.Short operator=null + FUN public fun stest4(/*0*/ a: kotlin.Short, /*1*/ b: kotlin.Short): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ + arg0: CALL .compareTo type=kotlin.Int operator=LTEQ + $this: GET_VAR a type=kotlin.Short operator=null + other: GET_VAR b type=kotlin.Short operator=null + FUN public fun itest1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun itest2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun itest3(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ + arg0: CALL .compareTo type=kotlin.Int operator=GTEQ + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun itest4(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ + arg0: CALL .compareTo type=kotlin.Int operator=LTEQ + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun ltest1(/*0*/ a: kotlin.Long, /*1*/ b: kotlin.Long): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: GET_VAR a type=kotlin.Long operator=null + other: GET_VAR b type=kotlin.Long operator=null + FUN public fun ltest2(/*0*/ a: kotlin.Long, /*1*/ b: kotlin.Long): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR a type=kotlin.Long operator=null + other: GET_VAR b type=kotlin.Long operator=null + FUN public fun ltest3(/*0*/ a: kotlin.Long, /*1*/ b: kotlin.Long): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ + arg0: CALL .compareTo type=kotlin.Int operator=GTEQ + $this: GET_VAR a type=kotlin.Long operator=null + other: GET_VAR b type=kotlin.Long operator=null + FUN public fun ltest4(/*0*/ a: kotlin.Long, /*1*/ b: kotlin.Long): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ + arg0: CALL .compareTo type=kotlin.Int operator=LTEQ + $this: GET_VAR a type=kotlin.Long operator=null + other: GET_VAR b type=kotlin.Long operator=null + FUN public fun ftest1(/*0*/ a: kotlin.Float, /*1*/ b: kotlin.Float): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: GET_VAR a type=kotlin.Float operator=null + other: GET_VAR b type=kotlin.Float operator=null + FUN public fun ftest2(/*0*/ a: kotlin.Float, /*1*/ b: kotlin.Float): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR a type=kotlin.Float operator=null + other: GET_VAR b type=kotlin.Float operator=null + FUN public fun ftest3(/*0*/ a: kotlin.Float, /*1*/ b: kotlin.Float): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ + arg0: CALL .compareTo type=kotlin.Int operator=GTEQ + $this: GET_VAR a type=kotlin.Float operator=null + other: GET_VAR b type=kotlin.Float operator=null + FUN public fun ftest4(/*0*/ a: kotlin.Float, /*1*/ b: kotlin.Float): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ + arg0: CALL .compareTo type=kotlin.Int operator=LTEQ + $this: GET_VAR a type=kotlin.Float operator=null + other: GET_VAR b type=kotlin.Float operator=null + FUN public fun dtest1(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Double): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: GET_VAR a type=kotlin.Double operator=null + other: GET_VAR b type=kotlin.Double operator=null + FUN public fun dtest2(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Double): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR a type=kotlin.Double operator=null + other: GET_VAR b type=kotlin.Double operator=null + FUN public fun dtest3(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Double): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ + arg0: CALL .compareTo type=kotlin.Int operator=GTEQ + $this: GET_VAR a type=kotlin.Double operator=null + other: GET_VAR b type=kotlin.Double operator=null + FUN public fun dtest4(/*0*/ a: kotlin.Double, /*1*/ b: kotlin.Double): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ + arg0: CALL .compareTo type=kotlin.Int operator=LTEQ + $this: GET_VAR a type=kotlin.Double operator=null + other: GET_VAR b type=kotlin.Double operator=null diff --git a/compiler/testData/ir/irText/references.txt b/compiler/testData/ir/irText/references.txt index 1a24de9a367..3d78d25e51f 100644 --- a/compiler/testData/ir/irText/references.txt +++ b/compiler/testData/ir/irText/references.txt @@ -1,47 +1,40 @@ -IrFile /references.kt - IrProperty public val ok: kotlin.String = "OK" getter=null setter=null - IrExpressionBody +FILE /references.kt + PROPERTY public val ok: kotlin.String = "OK" getter=null setter=null + EXPRESSION_BODY CONST String type=kotlin.String value='OK' - IrProperty public val ok2: kotlin.String = "OK" getter=null setter=null - IrExpressionBody + PROPERTY public val ok2: kotlin.String = "OK" getter=null setter=null + EXPRESSION_BODY CALL . type=kotlin.String operator=GET_PROPERTY - IrProperty public val ok3: kotlin.String getter= setter=null - IrPropertyGetter public fun (): kotlin.String property=ok3 - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST String type=kotlin.String value='OK' - IrFunction public fun test1(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL . type=kotlin.String operator=GET_PROPERTY - IrFunction public fun test2(/*0*/ x: kotlin.String): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - GET_VAR x type=kotlin.String operator=null - IrFunction public fun test3(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR val x: kotlin.String = "OK" - CONST String type=kotlin.String value='OK' - RETURN type= - GET_VAR x type=kotlin.String operator=null - IrFunction public fun test4(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL . type=kotlin.String operator=GET_PROPERTY - IrProperty public val kotlin.String.okext: kotlin.String getter= setter=null - IrPropertyGetter public fun kotlin.String.(): kotlin.String property=okext - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST String type=kotlin.String value='OK' - IrFunction public fun kotlin.String.test5(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL . type=kotlin.String operator=GET_PROPERTY - $receiver: $RECEIVER of: test5 type=kotlin.String + PROPERTY public val ok3: kotlin.String getter= setter=null + PROPERTY_GETTER public fun (): kotlin.String property=ok3 + BLOCK_BODY + RETURN type= + CONST String type=kotlin.String value='OK' + FUN public fun test1(): kotlin.String + BLOCK_BODY + RETURN type= + CALL . type=kotlin.String operator=GET_PROPERTY + FUN public fun test2(/*0*/ x: kotlin.String): kotlin.String + BLOCK_BODY + RETURN type= + GET_VAR x type=kotlin.String operator=null + FUN public fun test3(): kotlin.String + BLOCK_BODY + VAR val x: kotlin.String = "OK" + CONST String type=kotlin.String value='OK' + RETURN type= + GET_VAR x type=kotlin.String operator=null + FUN public fun test4(): kotlin.String + BLOCK_BODY + RETURN type= + CALL . type=kotlin.String operator=GET_PROPERTY + PROPERTY public val kotlin.String.okext: kotlin.String getter= setter=null + PROPERTY_GETTER public fun kotlin.String.(): kotlin.String property=okext + BLOCK_BODY + RETURN type= + CONST String type=kotlin.String value='OK' + FUN public fun kotlin.String.test5(): kotlin.String + BLOCK_BODY + RETURN type= + CALL . type=kotlin.String operator=GET_PROPERTY + $receiver: $RECEIVER of: test5 type=kotlin.String diff --git a/compiler/testData/ir/irText/safeCallWithIncrementDecrement.txt b/compiler/testData/ir/irText/safeCallWithIncrementDecrement.txt index a4da8c49083..600b67d37cc 100644 --- a/compiler/testData/ir/irText/safeCallWithIncrementDecrement.txt +++ b/compiler/testData/ir/irText/safeCallWithIncrementDecrement.txt @@ -1,69 +1,62 @@ -IrFile /safeCallWithIncrementDecrement.kt +FILE /safeCallWithIncrementDecrement.kt DUMMY C - IrProperty public var test.C?.p: kotlin.Int getter= setter= - IrPropertyGetter public fun test.C?.(): kotlin.Int property=p - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='42' - IrPropertySetter public fun test.C?.(/*0*/ value: kotlin.Int): kotlin.Unit property=p - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public operator fun kotlin.Int?.inc(): kotlin.Int? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Int? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: $RECEIVER of: inc type=kotlin.Int? - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL .inc type=kotlin.Int operator=null - $this: $RECEIVER of: inc type=kotlin.Int? - IrFunction public operator fun kotlin.Int?.get(/*0*/ index: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='42' - IrFunction public operator fun kotlin.Int?.set(/*0*/ index: kotlin.Int, /*1*/ value: kotlin.Int): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public fun testProperty(/*0*/ nc: test.C?): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null + PROPERTY public var test.C?.p: kotlin.Int getter= setter= + PROPERTY_GETTER public fun test.C?.(): kotlin.Int property=p + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='42' + PROPERTY_SETTER public fun test.C?.(/*0*/ value: kotlin.Int): kotlin.Unit property=p + BLOCK_BODY + FUN public operator fun kotlin.Int?.inc(): kotlin.Int? + BLOCK_BODY + RETURN type= WHEN type=kotlin.Int? operator=SAFE_CALL if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR nc type=test.C? operator=null + arg0: $RECEIVER of: inc type=kotlin.Int? arg1: CONST Null type=kotlin.Nothing? value='null' then: CONST Null type=kotlin.Nothing? value='null' - else: BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp1: kotlin.Int - CALL . type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR nc type=test.C? operator=null - CALL . type=kotlin.Unit operator=POSTFIX_INCR + else: CALL .inc type=kotlin.Int operator=null + $this: $RECEIVER of: inc type=kotlin.Int? + FUN public operator fun kotlin.Int?.get(/*0*/ index: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='42' + FUN public operator fun kotlin.Int?.set(/*0*/ index: kotlin.Int, /*1*/ value: kotlin.Int): kotlin.Unit + BLOCK_BODY + FUN public fun testProperty(/*0*/ nc: test.C?): kotlin.Unit + BLOCK_BODY + WHEN type=kotlin.Int? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR nc type=test.C? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp1: kotlin.Int + CALL . type=kotlin.Int operator=POSTFIX_INCR $this: GET_VAR nc type=test.C? operator=null - value: CALL .inc type=kotlin.Int? operator=POSTFIX_INCR - $receiver: GET_VAR tmp1 type=kotlin.Int operator=null - GET_VAR tmp1 type=kotlin.Int operator=null - IrFunction public fun testArrayAccess(/*0*/ nc: test.C?): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp3_array: kotlin.Int? - WHEN type=kotlin.Int? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR nc type=test.C? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL . type=kotlin.Int operator=GET_PROPERTY - $this: GET_VAR nc type=test.C? operator=null - VAR val tmp4: kotlin.Int - CALL .get type=kotlin.Int operator=POSTFIX_INCR - $receiver: GET_VAR tmp3_array type=kotlin.Int? operator=null - index: CONST Int type=kotlin.Int value='0' - CALL .set type=kotlin.Unit operator=POSTFIX_INCR + CALL . type=kotlin.Unit operator=POSTFIX_INCR + $this: GET_VAR nc type=test.C? operator=null + value: CALL .inc type=kotlin.Int? operator=POSTFIX_INCR + $receiver: GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp1 type=kotlin.Int operator=null + FUN public fun testArrayAccess(/*0*/ nc: test.C?): kotlin.Unit + BLOCK_BODY + BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp3_array: kotlin.Int? + WHEN type=kotlin.Int? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR nc type=test.C? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: CALL . type=kotlin.Int operator=GET_PROPERTY + $this: GET_VAR nc type=test.C? operator=null + VAR val tmp4: kotlin.Int + CALL .get type=kotlin.Int operator=POSTFIX_INCR $receiver: GET_VAR tmp3_array type=kotlin.Int? operator=null index: CONST Int type=kotlin.Int value='0' - value: CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp4 type=kotlin.Int operator=null - GET_VAR tmp4 type=kotlin.Int operator=null + CALL .set type=kotlin.Unit operator=POSTFIX_INCR + $receiver: GET_VAR tmp3_array type=kotlin.Int? operator=null + index: CONST Int type=kotlin.Int value='0' + value: CALL .inc type=kotlin.Int operator=POSTFIX_INCR + $this: GET_VAR tmp4 type=kotlin.Int operator=null + GET_VAR tmp4 type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/safeCalls.txt b/compiler/testData/ir/irText/safeCalls.txt index 574992d6a72..5a3beccf817 100644 --- a/compiler/testData/ir/irText/safeCalls.txt +++ b/compiler/testData/ir/irText/safeCalls.txt @@ -1,60 +1,55 @@ -IrFile /safeCalls.kt +FILE /safeCalls.kt DUMMY Ref DUMMY IHost - IrFunction public fun test1(/*0*/ x: kotlin.String?): kotlin.Int? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Int? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR x type=kotlin.String? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL . type=kotlin.Int operator=GET_PROPERTY - $this: GET_VAR x type=kotlin.String? operator=null - IrFunction public fun test2(/*0*/ x: kotlin.String?): kotlin.Int? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Int? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR x type=kotlin.String? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL .hashCode type=kotlin.Int operator=null - $this: GET_VAR x type=kotlin.String? operator=null - IrFunction public fun test3(/*0*/ x: kotlin.String?, /*1*/ y: kotlin.Any?): kotlin.Boolean? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Boolean? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR x type=kotlin.String? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL .equals type=kotlin.Boolean operator=null - $this: GET_VAR x type=kotlin.String? operator=null - other: GET_VAR y type=kotlin.Any? operator=null - IrFunction public fun test4(/*0*/ x: Ref?): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHEN type=kotlin.Unit? operator=SAFE_CALL + FUN public fun test1(/*0*/ x: kotlin.String?): kotlin.Int? + BLOCK_BODY + RETURN type= + WHEN type=kotlin.Int? operator=SAFE_CALL if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR x type=Ref? operator=null + arg0: GET_VAR x type=kotlin.String? operator=null arg1: CONST Null type=kotlin.Nothing? value='null' then: CONST Null type=kotlin.Nothing? value='null' - else: CALL . type=kotlin.Unit operator=EQ - $this: GET_VAR x type=Ref? operator=null - : CONST Int type=kotlin.Int value='0' - IrFunction public fun IHost.test5(/*0*/ s: kotlin.String?): kotlin.Int? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.Int? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR s type=kotlin.String? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL .extLength type=kotlin.Int operator=null - $this: $RECEIVER of: test5 type=IHost - $receiver: GET_VAR s type=kotlin.String? operator=null + else: CALL . type=kotlin.Int operator=GET_PROPERTY + $this: GET_VAR x type=kotlin.String? operator=null + FUN public fun test2(/*0*/ x: kotlin.String?): kotlin.Int? + BLOCK_BODY + RETURN type= + WHEN type=kotlin.Int? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR x type=kotlin.String? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: CALL .hashCode type=kotlin.Int operator=null + $this: GET_VAR x type=kotlin.String? operator=null + FUN public fun test3(/*0*/ x: kotlin.String?, /*1*/ y: kotlin.Any?): kotlin.Boolean? + BLOCK_BODY + RETURN type= + WHEN type=kotlin.Boolean? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR x type=kotlin.String? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: CALL .equals type=kotlin.Boolean operator=null + $this: GET_VAR x type=kotlin.String? operator=null + other: GET_VAR y type=kotlin.Any? operator=null + FUN public fun test4(/*0*/ x: Ref?): kotlin.Unit + BLOCK_BODY + WHEN type=kotlin.Unit? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR x type=Ref? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: CALL . type=kotlin.Unit operator=EQ + $this: GET_VAR x type=Ref? operator=null + : CONST Int type=kotlin.Int value='0' + FUN public fun IHost.test5(/*0*/ s: kotlin.String?): kotlin.Int? + BLOCK_BODY + RETURN type= + WHEN type=kotlin.Int? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR s type=kotlin.String? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: CALL .extLength type=kotlin.Int operator=null + $this: $RECEIVER of: test5 type=IHost + $receiver: GET_VAR s type=kotlin.String? operator=null diff --git a/compiler/testData/ir/irText/simpleOperators.txt b/compiler/testData/ir/irText/simpleOperators.txt index 3b7bf86ceb1..07313ae5ef2 100644 --- a/compiler/testData/ir/irText/simpleOperators.txt +++ b/compiler/testData/ir/irText/simpleOperators.txt @@ -1,78 +1,67 @@ -IrFile /simpleOperators.kt - IrFunction public fun test1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .plus type=kotlin.Int operator=PLUS - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .minus type=kotlin.Int operator=MINUS - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test3(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .times type=kotlin.Int operator=MUL - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test4(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .div type=kotlin.Int operator=DIV - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test5(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .mod type=kotlin.Int operator=PERC - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test6(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.ranges.IntRange - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .rangeTo type=kotlin.ranges.IntRange operator=RANGE - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test1x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .plus type=kotlin.Int operator=null - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test2x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .minus type=kotlin.Int operator=null - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test3x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .times type=kotlin.Int operator=null - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test4x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .div type=kotlin.Int operator=null - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test5x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .mod type=kotlin.Int operator=null - $this: GET_VAR a type=kotlin.Int operator=null - other: GET_VAR b type=kotlin.Int operator=null +FILE /simpleOperators.kt + FUN public fun test1(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .plus type=kotlin.Int operator=PLUS + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test2(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .minus type=kotlin.Int operator=MINUS + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test3(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .times type=kotlin.Int operator=MUL + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test4(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .div type=kotlin.Int operator=DIV + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test5(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .mod type=kotlin.Int operator=PERC + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test6(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.ranges.IntRange + BLOCK_BODY + RETURN type= + CALL .rangeTo type=kotlin.ranges.IntRange operator=RANGE + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test1x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .plus type=kotlin.Int operator=null + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test2x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .minus type=kotlin.Int operator=null + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test3x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .times type=kotlin.Int operator=null + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test4x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .div type=kotlin.Int operator=null + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null + FUN public fun test5x(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .mod type=kotlin.Int operator=null + $this: GET_VAR a type=kotlin.Int operator=null + other: GET_VAR b type=kotlin.Int operator=null diff --git a/compiler/testData/ir/irText/simpleUnaryOperators.txt b/compiler/testData/ir/irText/simpleUnaryOperators.txt index 14cb53d7b60..3cafbfa6138 100644 --- a/compiler/testData/ir/irText/simpleUnaryOperators.txt +++ b/compiler/testData/ir/irText/simpleUnaryOperators.txt @@ -1,37 +1,31 @@ -IrFile /simpleUnaryOperators.kt - IrFunction public fun test1(/*0*/ x: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .unaryMinus type=kotlin.Int operator=UMINUS - $this: GET_VAR x type=kotlin.Int operator=null - IrFunction public fun test2(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .unaryMinus type=kotlin.Int operator=UMINUS - $this: CONST Int type=kotlin.Int value='42' - IrFunction public fun test3(/*0*/ x: kotlin.Int): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .unaryPlus type=kotlin.Int operator=UPLUS - $this: GET_VAR x type=kotlin.Int operator=null - IrFunction public fun test4(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .unaryPlus type=kotlin.Int operator=UPLUS - $this: CONST Int type=kotlin.Int value='42' - IrFunction public fun test5(/*0*/ x: kotlin.Boolean): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .not type=kotlin.Boolean operator=EXCL - $this: GET_VAR x type=kotlin.Boolean operator=null - IrFunction public fun test6(): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .not type=kotlin.Boolean operator=EXCL - $this: CONST Boolean type=kotlin.Boolean value='true' +FILE /simpleUnaryOperators.kt + FUN public fun test1(/*0*/ x: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .unaryMinus type=kotlin.Int operator=UMINUS + $this: GET_VAR x type=kotlin.Int operator=null + FUN public fun test2(): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .unaryMinus type=kotlin.Int operator=UMINUS + $this: CONST Int type=kotlin.Int value='42' + FUN public fun test3(/*0*/ x: kotlin.Int): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .unaryPlus type=kotlin.Int operator=UPLUS + $this: GET_VAR x type=kotlin.Int operator=null + FUN public fun test4(): kotlin.Int + BLOCK_BODY + RETURN type= + CALL .unaryPlus type=kotlin.Int operator=UPLUS + $this: CONST Int type=kotlin.Int value='42' + FUN public fun test5(/*0*/ x: kotlin.Boolean): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .not type=kotlin.Boolean operator=EXCL + $this: GET_VAR x type=kotlin.Boolean operator=null + FUN public fun test6(): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .not type=kotlin.Boolean operator=EXCL + $this: CONST Boolean type=kotlin.Boolean value='true' diff --git a/compiler/testData/ir/irText/smartCasts.txt b/compiler/testData/ir/irText/smartCasts.txt index 45ba5940157..67e25f75857 100644 --- a/compiler/testData/ir/irText/smartCasts.txt +++ b/compiler/testData/ir/irText/smartCasts.txt @@ -1,62 +1,55 @@ -IrFile /smartCasts.kt - IrFunction public fun expectsString(/*0*/ s: kotlin.String): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public fun expectsInt(/*0*/ i: kotlin.Int): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - IrFunction public fun overloaded(/*0*/ s: kotlin.String): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - GET_VAR s type=kotlin.String operator=null - IrFunction public fun overloaded(/*0*/ x: kotlin.Any): kotlin.Any - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= +FILE /smartCasts.kt + FUN public fun expectsString(/*0*/ s: kotlin.String): kotlin.Unit + BLOCK_BODY + FUN public fun expectsInt(/*0*/ i: kotlin.Int): kotlin.Unit + BLOCK_BODY + FUN public fun overloaded(/*0*/ s: kotlin.String): kotlin.String + BLOCK_BODY + RETURN type= + GET_VAR s type=kotlin.String operator=null + FUN public fun overloaded(/*0*/ x: kotlin.Any): kotlin.Any + BLOCK_BODY + RETURN type= + GET_VAR x type=kotlin.Any operator=null + FUN public fun test1(/*0*/ x: kotlin.Any): kotlin.Unit + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String GET_VAR x type=kotlin.Any operator=null - IrFunction public fun test1(/*0*/ x: kotlin.Any): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String + then: RETURN type= + CALL .println type=kotlin.Unit operator=null + message: CALL . type=kotlin.Int operator=GET_PROPERTY + $this: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String GET_VAR x type=kotlin.Any operator=null - then: RETURN type= - CALL .println type=kotlin.Unit operator=null - message: CALL . type=kotlin.Int operator=GET_PROPERTY - $this: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String - GET_VAR x type=kotlin.Any operator=null - CALL .expectsString type=kotlin.Unit operator=null + CALL .expectsString type=kotlin.Unit operator=null + s: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR x type=kotlin.Any operator=null + CALL .expectsInt type=kotlin.Unit operator=null + i: CALL . type=kotlin.Int operator=GET_PROPERTY + $this: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR x type=kotlin.Any operator=null + CALL .expectsString type=kotlin.Unit operator=null + s: CALL .overloaded type=kotlin.String operator=null s: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String GET_VAR x type=kotlin.Any operator=null - CALL .expectsInt type=kotlin.Unit operator=null - i: CALL . type=kotlin.Int operator=GET_PROPERTY - $this: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String - GET_VAR x type=kotlin.Any operator=null - CALL .expectsString type=kotlin.Unit operator=null - s: CALL .overloaded type=kotlin.String operator=null - s: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String - GET_VAR x type=kotlin.Any operator=null - IrFunction public fun test2(/*0*/ x: kotlin.Any): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR x type=kotlin.Any operator=null - then: RETURN type= - CONST String type=kotlin.String value='' - RETURN type= - CALL .overloaded type=kotlin.String operator=null - s: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String - GET_VAR x type=kotlin.Any operator=null - IrFunction public fun test3(/*0*/ x: kotlin.Any): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR x type=kotlin.Any operator=null - then: RETURN type= - CONST String type=kotlin.String value='' - RETURN type= - TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String + FUN public fun test2(/*0*/ x: kotlin.Any): kotlin.String + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR x type=kotlin.Any operator=null + then: RETURN type= + CONST String type=kotlin.String value='' + RETURN type= + CALL .overloaded type=kotlin.String operator=null + s: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String GET_VAR x type=kotlin.Any operator=null + FUN public fun test3(/*0*/ x: kotlin.Any): kotlin.String + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR x type=kotlin.Any operator=null + then: RETURN type= + CONST String type=kotlin.String value='' + RETURN type= + TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR x type=kotlin.Any operator=null diff --git a/compiler/testData/ir/irText/smartCastsWithDestructuring.txt b/compiler/testData/ir/irText/smartCastsWithDestructuring.txt index 1c7e5260c19..71787f20856 100644 --- a/compiler/testData/ir/irText/smartCastsWithDestructuring.txt +++ b/compiler/testData/ir/irText/smartCastsWithDestructuring.txt @@ -1,28 +1,25 @@ -IrFile /smartCastsWithDestructuring.kt +FILE /smartCastsWithDestructuring.kt DUMMY I1 DUMMY I2 - IrFunction public operator fun I1.component1(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='1' - IrFunction public operator fun I2.component2(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST String type=kotlin.String value='' - IrFunction public fun test(/*0*/ x: I1): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=I2 - GET_VAR x type=I1 operator=null - then: RETURN type= - BLOCK type= hasResult=false operator=SYNTHETIC_BLOCK - VAR val c1: kotlin.Int - CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1) - $receiver: GET_VAR x type=I1 operator=null - VAR val c2: kotlin.String - CALL .component2 type=kotlin.String operator=COMPONENT_N(index=2) - $receiver: TYPE_OP operator=IMPLICIT_CAST typeOperand=I2 - GET_VAR x type=I1 operator=null + FUN public operator fun I1.component1(): kotlin.Int + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='1' + FUN public operator fun I2.component2(): kotlin.String + BLOCK_BODY + RETURN type= + CONST String type=kotlin.String value='' + FUN public fun test(/*0*/ x: I1): kotlin.Unit + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=I2 + GET_VAR x type=I1 operator=null + then: RETURN type= + BLOCK type=kotlin.Unit operator=DESTRUCTURING_DECLARATION + VAR val c1: kotlin.Int + CALL .component1 type=kotlin.Int operator=COMPONENT_N(index=1) + $receiver: GET_VAR x type=I1 operator=null + VAR val c2: kotlin.String + CALL .component2 type=kotlin.String operator=COMPONENT_N(index=2) + $receiver: TYPE_OP operator=IMPLICIT_CAST typeOperand=I2 + GET_VAR x type=I1 operator=null diff --git a/compiler/testData/ir/irText/smoke.kt b/compiler/testData/ir/irText/smoke.kt index 6dee242ca5e..d32b7fb0bef 100644 --- a/compiler/testData/ir/irText/smoke.kt +++ b/compiler/testData/ir/irText/smoke.kt @@ -6,10 +6,7 @@ var testVarWithAccessors: Int get() = 42 set(v) {} -// 1 IrFunction public fun testFun -// 1 IrProperty public val testSimpleVal -// 1 IrProperty public val testValWithGetter -// 2 IrPropertyGetter -// 1 IrPropertySetter -// 1 IrProperty public var testSimpleVar -// 1 IrProperty public var testVarWithAccessors \ No newline at end of file +// 1 FUN public fun testFun +// 1 PROPERTY public val testSimpleVal +// 2 PROPERTY_GETTER +// 1 PROPERTY_SETTER diff --git a/compiler/testData/ir/irText/smoke.txt b/compiler/testData/ir/irText/smoke.txt index dd94191b4a5..36320275465 100644 --- a/compiler/testData/ir/irText/smoke.txt +++ b/compiler/testData/ir/irText/smoke.txt @@ -1,27 +1,23 @@ -IrFile /smoke.kt - IrFunction public fun testFun(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST String type=kotlin.String value='OK' - IrProperty public val testSimpleVal: kotlin.Int = 1 getter=null setter=null - IrExpressionBody +FILE /smoke.kt + FUN public fun testFun(): kotlin.String + BLOCK_BODY + RETURN type= + CONST String type=kotlin.String value='OK' + PROPERTY public val testSimpleVal: kotlin.Int = 1 getter=null setter=null + EXPRESSION_BODY CONST Int type=kotlin.Int value='1' - IrProperty public val testValWithGetter: kotlin.Int getter= setter=null - IrPropertyGetter public fun (): kotlin.Int property=testValWithGetter - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='42' - IrProperty public var testSimpleVar: kotlin.Int getter=null setter=null - IrExpressionBody + PROPERTY public val testValWithGetter: kotlin.Int getter= setter=null + PROPERTY_GETTER public fun (): kotlin.Int property=testValWithGetter + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='42' + PROPERTY public var testSimpleVar: kotlin.Int getter=null setter=null + EXPRESSION_BODY CONST Int type=kotlin.Int value='2' - IrProperty public var testVarWithAccessors: kotlin.Int getter= setter= - IrPropertyGetter public fun (): kotlin.Int property=testVarWithAccessors - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CONST Int type=kotlin.Int value='42' - IrPropertySetter public fun (/*0*/ v: kotlin.Int): kotlin.Unit property=testVarWithAccessors - IrExpressionBody - BLOCK type= hasResult=false operator=null + PROPERTY public var testVarWithAccessors: kotlin.Int getter= setter= + PROPERTY_GETTER public fun (): kotlin.Int property=testVarWithAccessors + BLOCK_BODY + RETURN type= + CONST Int type=kotlin.Int value='42' + PROPERTY_SETTER public fun (/*0*/ v: kotlin.Int): kotlin.Unit property=testVarWithAccessors + BLOCK_BODY diff --git a/compiler/testData/ir/irText/stringComparisons.txt b/compiler/testData/ir/irText/stringComparisons.txt index 9a82efa9f14..0c376d3f4e2 100644 --- a/compiler/testData/ir/irText/stringComparisons.txt +++ b/compiler/testData/ir/irText/stringComparisons.txt @@ -1,33 +1,29 @@ -IrFile /stringComparisons.kt - IrFunction public fun test1(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GT0 type=kotlin.Boolean operator=GT - arg0: CALL .compareTo type=kotlin.Int operator=GT - $this: GET_VAR a type=kotlin.String operator=null - other: GET_VAR b type=kotlin.String operator=null - IrFunction public fun test2(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR a type=kotlin.String operator=null - other: GET_VAR b type=kotlin.String operator=null - IrFunction public fun test3(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ - arg0: CALL .compareTo type=kotlin.Int operator=GTEQ - $this: GET_VAR a type=kotlin.String operator=null - other: GET_VAR b type=kotlin.String operator=null - IrFunction public fun test4(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ - arg0: CALL .compareTo type=kotlin.Int operator=LTEQ - $this: GET_VAR a type=kotlin.String operator=null - other: GET_VAR b type=kotlin.String operator=null +FILE /stringComparisons.kt + FUN public fun test1(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GT0 type=kotlin.Boolean operator=GT + arg0: CALL .compareTo type=kotlin.Int operator=GT + $this: GET_VAR a type=kotlin.String operator=null + other: GET_VAR b type=kotlin.String operator=null + FUN public fun test2(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR a type=kotlin.String operator=null + other: GET_VAR b type=kotlin.String operator=null + FUN public fun test3(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .GTEQ0 type=kotlin.Boolean operator=GTEQ + arg0: CALL .compareTo type=kotlin.Int operator=GTEQ + $this: GET_VAR a type=kotlin.String operator=null + other: GET_VAR b type=kotlin.String operator=null + FUN public fun test4(/*0*/ a: kotlin.String, /*1*/ b: kotlin.String): kotlin.Boolean + BLOCK_BODY + RETURN type= + CALL .LTEQ0 type=kotlin.Boolean operator=LTEQ + arg0: CALL .compareTo type=kotlin.Int operator=LTEQ + $this: GET_VAR a type=kotlin.String operator=null + other: GET_VAR b type=kotlin.String operator=null diff --git a/compiler/testData/ir/irText/stringPlus.txt b/compiler/testData/ir/irText/stringPlus.txt index 527c9084ce8..d1abdb8dc67 100644 --- a/compiler/testData/ir/irText/stringPlus.txt +++ b/compiler/testData/ir/irText/stringPlus.txt @@ -1,27 +1,24 @@ -IrFile /stringPlus.kt - IrFunction public fun test1(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Any): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - STRING_CONCATENATION type=kotlin.String - GET_VAR a type=kotlin.String operator=null - GET_VAR b type=kotlin.Any operator=null - IrFunction public fun test2(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - STRING_CONCATENATION type=kotlin.String - GET_VAR a type=kotlin.String operator=null - CONST String type=kotlin.String value='+' - GET_VAR b type=kotlin.Int operator=null - IrFunction public fun test3(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - STRING_CONCATENATION type=kotlin.String - GET_VAR a type=kotlin.String operator=null - CONST String type=kotlin.String value='+' - CALL .plus type=kotlin.Int operator=PLUS - $this: GET_VAR b type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='1' - GET_VAR a type=kotlin.String operator=null +FILE /stringPlus.kt + FUN public fun test1(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Any): kotlin.String + BLOCK_BODY + RETURN type= + STRING_CONCATENATION type=kotlin.String + GET_VAR a type=kotlin.String operator=null + GET_VAR b type=kotlin.Any operator=null + FUN public fun test2(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int): kotlin.String + BLOCK_BODY + RETURN type= + STRING_CONCATENATION type=kotlin.String + GET_VAR a type=kotlin.String operator=null + CONST String type=kotlin.String value='+' + GET_VAR b type=kotlin.Int operator=null + FUN public fun test3(/*0*/ a: kotlin.String, /*1*/ b: kotlin.Int): kotlin.String + BLOCK_BODY + RETURN type= + STRING_CONCATENATION type=kotlin.String + GET_VAR a type=kotlin.String operator=null + CONST String type=kotlin.String value='+' + CALL .plus type=kotlin.Int operator=PLUS + $this: GET_VAR b type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='1' + GET_VAR a type=kotlin.String operator=null diff --git a/compiler/testData/ir/irText/throw.txt b/compiler/testData/ir/irText/throw.txt index 4dbb65d3b8a..c30f7d9e19f 100644 --- a/compiler/testData/ir/irText/throw.txt +++ b/compiler/testData/ir/irText/throw.txt @@ -1,16 +1,14 @@ -IrFile /throw.kt - IrFunction public fun test1(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - THROW type= - CALL . type=kotlin.Throwable operator=null - IrFunction public fun testImplicitCast(/*0*/ a: kotlin.Any): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.Throwable - GET_VAR a type=kotlin.Any operator=null - then: BLOCK type= hasResult=false operator=null - THROW type= - TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Throwable - GET_VAR a type=kotlin.Any operator=null +FILE /throw.kt + FUN public fun test1(): kotlin.Unit + BLOCK_BODY + THROW type= + CALL . type=kotlin.Throwable operator=null + FUN public fun testImplicitCast(/*0*/ a: kotlin.Any): kotlin.Unit + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.Throwable + GET_VAR a type=kotlin.Any operator=null + then: BLOCK type=kotlin.Nothing operator=null + THROW type= + TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Throwable + GET_VAR a type=kotlin.Any operator=null diff --git a/compiler/testData/ir/irText/tryCatch.kt b/compiler/testData/ir/irText/tryCatch.kt index 3f6c3dfc340..f0ddffd83c7 100644 --- a/compiler/testData/ir/irText/tryCatch.kt +++ b/compiler/testData/ir/irText/tryCatch.kt @@ -23,9 +23,3 @@ fun test2(): Int { println() } } - -fun testImplicitCast(a: Any) { - if (a !is String) return - - val t: String = try { a } catch (e: Throwable) { "" } -} \ No newline at end of file diff --git a/compiler/testData/ir/irText/tryCatch.txt b/compiler/testData/ir/irText/tryCatch.txt index 51f87dafa82..7ff17e87afb 100644 --- a/compiler/testData/ir/irText/tryCatch.txt +++ b/compiler/testData/ir/irText/tryCatch.txt @@ -1,38 +1,22 @@ -IrFile /tryCatch.kt - IrFunction public fun test1(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - TRY_CATCH type=kotlin.Unit - try: BLOCK type= hasResult=false operator=null +FILE /tryCatch.kt + FUN public fun test1(): kotlin.Unit + BLOCK_BODY + TRY_CATCH type=kotlin.Unit + try: BLOCK type=kotlin.Unit operator=null + CALL .println type=kotlin.Unit operator=null + catch e: BLOCK type=kotlin.Unit operator=null + CALL .println type=kotlin.Unit operator=null + finally: BLOCK type=kotlin.Unit operator=null + CALL .println type=kotlin.Unit operator=null + FUN public fun test2(): kotlin.Int + BLOCK_BODY + RETURN type= + TRY_CATCH type=kotlin.Int + try: BLOCK type=kotlin.Int operator=null CALL .println type=kotlin.Unit operator=null - catch e: BLOCK type= hasResult=false operator=null + CONST Int type=kotlin.Int value='42' + catch e: BLOCK type=kotlin.Int operator=null CALL .println type=kotlin.Unit operator=null - finally: BLOCK type= hasResult=false operator=null + CONST Int type=kotlin.Int value='24' + finally: BLOCK type=kotlin.Unit operator=null CALL .println type=kotlin.Unit operator=null - IrFunction public fun test2(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - TRY_CATCH type=kotlin.Int - try: BLOCK type=kotlin.Int hasResult=true operator=null - CALL .println type=kotlin.Unit operator=null - CONST Int type=kotlin.Int value='42' - catch e: BLOCK type=kotlin.Int hasResult=true operator=null - CALL .println type=kotlin.Unit operator=null - CONST Int type=kotlin.Int value='24' - finally: BLOCK type= hasResult=false operator=null - CALL .println type=kotlin.Unit operator=null - IrFunction public fun testImplicitCast(/*0*/ a: kotlin.Any): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR a type=kotlin.Any operator=null - then: RETURN type= - VAR val t: kotlin.String - TRY_CATCH type=kotlin.String - try: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String - BLOCK type=kotlin.Any hasResult=true operator=null - GET_VAR a type=kotlin.Any operator=null - catch e: BLOCK type=kotlin.String hasResult=true operator=null - CONST String type=kotlin.String value='' diff --git a/compiler/testData/ir/irText/tryCatchWithImplicitCast.kt b/compiler/testData/ir/irText/tryCatchWithImplicitCast.kt new file mode 100644 index 00000000000..7e91a20aaed --- /dev/null +++ b/compiler/testData/ir/irText/tryCatchWithImplicitCast.kt @@ -0,0 +1,5 @@ +fun testImplicitCast(a: Any) { + if (a !is String) return + + val t: String = try { a } catch (e: Throwable) { "" } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/tryCatchWithImplicitCast.txt b/compiler/testData/ir/irText/tryCatchWithImplicitCast.txt new file mode 100644 index 00000000000..927ddca5a3d --- /dev/null +++ b/compiler/testData/ir/irText/tryCatchWithImplicitCast.txt @@ -0,0 +1,14 @@ +FILE /tryCatchWithImplicitCast.kt + FUN public fun testImplicitCast(/*0*/ a: kotlin.Any): kotlin.Unit + BLOCK_BODY + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR a type=kotlin.Any operator=null + then: RETURN type= + VAR val t: kotlin.String + TRY_CATCH type=kotlin.String + try: BLOCK type=kotlin.String operator=null + TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR a type=kotlin.Any operator=null + catch e: BLOCK type=kotlin.String operator=null + CONST String type=kotlin.String value='' diff --git a/compiler/testData/ir/irText/typeOperators.txt b/compiler/testData/ir/irText/typeOperators.txt index b6b416841b7..3e463fc3349 100644 --- a/compiler/testData/ir/irText/typeOperators.txt +++ b/compiler/testData/ir/irText/typeOperators.txt @@ -1,26 +1,22 @@ -IrFile /typeOperators.kt +FILE /typeOperators.kt DUMMY IThing - IrFunction public fun test1(/*0*/ x: kotlin.Any): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - TYPE_OP operator=INSTANCEOF typeOperand=IThing - GET_VAR x type=kotlin.Any operator=null - IrFunction public fun test2(/*0*/ x: kotlin.Any): kotlin.Boolean - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - TYPE_OP operator=NOT_INSTANCEOF typeOperand=IThing - GET_VAR x type=kotlin.Any operator=null - IrFunction public fun test3(/*0*/ x: kotlin.Any): IThing - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - TYPE_OP operator=CAST typeOperand=IThing - GET_VAR x type=kotlin.Any operator=null - IrFunction public fun test4(/*0*/ x: kotlin.Any): IThing? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - TYPE_OP operator=SAFE_CAST typeOperand=IThing - GET_VAR x type=kotlin.Any operator=null + FUN public fun test1(/*0*/ x: kotlin.Any): kotlin.Boolean + BLOCK_BODY + RETURN type= + TYPE_OP operator=INSTANCEOF typeOperand=IThing + GET_VAR x type=kotlin.Any operator=null + FUN public fun test2(/*0*/ x: kotlin.Any): kotlin.Boolean + BLOCK_BODY + RETURN type= + TYPE_OP operator=NOT_INSTANCEOF typeOperand=IThing + GET_VAR x type=kotlin.Any operator=null + FUN public fun test3(/*0*/ x: kotlin.Any): IThing + BLOCK_BODY + RETURN type= + TYPE_OP operator=CAST typeOperand=IThing + GET_VAR x type=kotlin.Any operator=null + FUN public fun test4(/*0*/ x: kotlin.Any): IThing? + BLOCK_BODY + RETURN type= + TYPE_OP operator=SAFE_CAST typeOperand=IThing + GET_VAR x type=kotlin.Any operator=null diff --git a/compiler/testData/ir/irText/values.txt b/compiler/testData/ir/irText/values.txt index 583d7945697..4bf4b9bd526 100644 --- a/compiler/testData/ir/irText/values.txt +++ b/compiler/testData/ir/irText/values.txt @@ -1,27 +1,23 @@ -IrFile /values.kt +FILE /values.kt DUMMY Enum DUMMY A - IrProperty public val a: kotlin.Int = 0 getter=null setter=null - IrExpressionBody + PROPERTY public val a: kotlin.Int = 0 getter=null setter=null + EXPRESSION_BODY CONST Int type=kotlin.Int value='0' DUMMY Z - IrFunction public fun test1(): Enum - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - GET_ENUM_VALUE A type=Enum - IrFunction public fun test2(): A - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - GET_OBJECT A type=A - IrFunction public fun test3(): kotlin.Int - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL . type=kotlin.Int operator=GET_PROPERTY - IrFunction public fun test4(): Z.Companion - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - GET_OBJECT Companion type=Z.Companion + FUN public fun test1(): Enum + BLOCK_BODY + RETURN type= + GET_ENUM_VALUE A type=Enum + FUN public fun test2(): A + BLOCK_BODY + RETURN type= + GET_OBJECT A type=A + FUN public fun test3(): kotlin.Int + BLOCK_BODY + RETURN type= + CALL . type=kotlin.Int operator=GET_PROPERTY + FUN public fun test4(): Z.Companion + BLOCK_BODY + RETURN type= + GET_OBJECT Companion type=Z.Companion diff --git a/compiler/testData/ir/irText/variableAsFunctionCall.txt b/compiler/testData/ir/irText/variableAsFunctionCall.txt index 8bad4fce1d1..0f9f13e8864 100644 --- a/compiler/testData/ir/irText/variableAsFunctionCall.txt +++ b/compiler/testData/ir/irText/variableAsFunctionCall.txt @@ -1,38 +1,33 @@ -IrFile /variableAsFunctionCall.kt - IrFunction public fun kotlin.String.k(): () -> kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - DUMMY KtLambdaExpression type=() -> kotlin.String - IrFunction public fun test1(/*0*/ f: () -> kotlin.Unit): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .invoke type=kotlin.Unit operator=INVOKE - $this: GET_VAR f type=() -> kotlin.Unit operator=VARIABLE_AS_FUNCTION - IrFunction public fun test2(/*0*/ f: kotlin.String.() -> kotlin.Unit): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .invoke type=kotlin.Unit operator=INVOKE - $this: GET_VAR f type=kotlin.String.() -> kotlin.Unit operator=VARIABLE_AS_FUNCTION +FILE /variableAsFunctionCall.kt + FUN public fun kotlin.String.k(): () -> kotlin.String + BLOCK_BODY + RETURN type= + DUMMY KtLambdaExpression type=() -> kotlin.String + FUN public fun test1(/*0*/ f: () -> kotlin.Unit): kotlin.Unit + BLOCK_BODY + RETURN type= + CALL .invoke type=kotlin.Unit operator=INVOKE + $this: GET_VAR f type=() -> kotlin.Unit operator=VARIABLE_AS_FUNCTION + FUN public fun test2(/*0*/ f: kotlin.String.() -> kotlin.Unit): kotlin.Unit + BLOCK_BODY + RETURN type= + CALL .invoke type=kotlin.Unit operator=INVOKE + $this: GET_VAR f type=kotlin.String.() -> kotlin.Unit operator=VARIABLE_AS_FUNCTION + $receiver: CONST String type=kotlin.String value='hello' + FUN public fun test3(): kotlin.String + BLOCK_BODY + RETURN type= + CALL .invoke type=kotlin.String operator=null + $this: CALL .k type=() -> kotlin.String operator=null $receiver: CONST String type=kotlin.String value='hello' - IrFunction public fun test3(): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - CALL .invoke type=kotlin.String operator=null + FUN public fun test4(/*0*/ ns: kotlin.String?): kotlin.String? + BLOCK_BODY + RETURN type= + WHEN type=kotlin.String? operator=SAFE_CALL + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR ns type=kotlin.String? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + else: CALL .invoke type=kotlin.String operator=null $this: CALL .k type=() -> kotlin.String operator=null - $receiver: CONST String type=kotlin.String value='hello' - IrFunction public fun test4(/*0*/ ns: kotlin.String?): kotlin.String? - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - WHEN type=kotlin.String? operator=SAFE_CALL - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR ns type=kotlin.String? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL .invoke type=kotlin.String operator=null - $this: CALL .k type=() -> kotlin.String operator=null - $this: GET_VAR ns type=kotlin.String? operator=null + $this: GET_VAR ns type=kotlin.String? operator=null diff --git a/compiler/testData/ir/irText/when.txt b/compiler/testData/ir/irText/when.txt index 4f8654c0a11..1c359995c62 100644 --- a/compiler/testData/ir/irText/when.txt +++ b/compiler/testData/ir/irText/when.txt @@ -1,98 +1,95 @@ -IrFile /when.kt +FILE /when.kt DUMMY A - IrFunction public fun testWithSubject(/*0*/ x: kotlin.Any?): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - BLOCK type=kotlin.String hasResult=true operator=WHEN - VAR val tmp0_subject: kotlin.Any? - GET_VAR x type=kotlin.Any? operator=null - WHEN type=kotlin.String operator=WHEN - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp0_subject type=kotlin.Any? operator=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST String type=kotlin.String value='null' - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp0_subject type=kotlin.Any? operator=null - arg1: GET_OBJECT A type=A - then: CONST String type=kotlin.String value='A' - if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.String - GET_VAR tmp0_subject type=kotlin.Any? operator=null - then: CONST String type=kotlin.String value='String' - if: CALL .contains type=kotlin.Boolean operator=IN - $receiver: CALL .setOf type=kotlin.collections.Set operator=null - element: GET_VAR tmp0_subject type=kotlin.Any? operator=null - then: CONST String type=kotlin.String value='nothingness?' - else: CONST String type=kotlin.String value='something' - IrFunction public fun test(/*0*/ x: kotlin.Any?): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= + FUN public fun testWithSubject(/*0*/ x: kotlin.Any?): kotlin.String + BLOCK_BODY + RETURN type= + BLOCK type=kotlin.String operator=WHEN + VAR val tmp0_subject: kotlin.Any? + GET_VAR x type=kotlin.Any? operator=null WHEN type=kotlin.String operator=WHEN if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR x type=kotlin.Any? operator=null + arg0: GET_VAR tmp0_subject type=kotlin.Any? operator=null arg1: CONST Null type=kotlin.Nothing? value='null' then: CONST String type=kotlin.String value='null' if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR x type=kotlin.Any? operator=null + arg0: GET_VAR tmp0_subject type=kotlin.Any? operator=null arg1: GET_OBJECT A type=A then: CONST String type=kotlin.String value='A' if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.String - GET_VAR x type=kotlin.Any? operator=null + GET_VAR tmp0_subject type=kotlin.Any? operator=null then: CONST String type=kotlin.String value='String' if: CALL .contains type=kotlin.Boolean operator=IN $receiver: CALL .setOf type=kotlin.collections.Set operator=null - element: GET_VAR x type=kotlin.Any? operator=null + element: GET_VAR tmp0_subject type=kotlin.Any? operator=null then: CONST String type=kotlin.String value='nothingness?' else: CONST String type=kotlin.String value='something' - IrFunction public fun testComma(/*0*/ x: kotlin.Int): kotlin.String - IrExpressionBody - BLOCK type= hasResult=false operator=null - RETURN type= - BLOCK type=kotlin.String hasResult=true operator=WHEN - VAR val tmp0_subject: kotlin.Int - GET_VAR x type=kotlin.Int operator=null - WHEN type=kotlin.String operator=WHEN - if: WHEN type=kotlin.Boolean operator=WHEN_COMMA - if: WHEN type=kotlin.Boolean operator=WHEN_COMMA - if: WHEN type=kotlin.Boolean operator=WHEN_COMMA - if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='1' - then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='2' - then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='3' - then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ - arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='4' - then: CONST String type=kotlin.String value='1234' + FUN public fun test(/*0*/ x: kotlin.Any?): kotlin.String + BLOCK_BODY + RETURN type= + WHEN type=kotlin.String operator=WHEN + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR x type=kotlin.Any? operator=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST String type=kotlin.String value='null' + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR x type=kotlin.Any? operator=null + arg1: GET_OBJECT A type=A + then: CONST String type=kotlin.String value='A' + if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.String + GET_VAR x type=kotlin.Any? operator=null + then: CONST String type=kotlin.String value='String' + if: CALL .contains type=kotlin.Boolean operator=IN + $receiver: CALL .setOf type=kotlin.collections.Set operator=null + element: GET_VAR x type=kotlin.Any? operator=null + then: CONST String type=kotlin.String value='nothingness?' + else: CONST String type=kotlin.String value='something' + FUN public fun testComma(/*0*/ x: kotlin.Int): kotlin.String + BLOCK_BODY + RETURN type= + BLOCK type=kotlin.String operator=WHEN + VAR val tmp0_subject: kotlin.Int + GET_VAR x type=kotlin.Int operator=null + WHEN type=kotlin.String operator=WHEN + if: WHEN type=kotlin.Boolean operator=WHEN_COMMA if: WHEN type=kotlin.Boolean operator=WHEN_COMMA if: WHEN type=kotlin.Boolean operator=WHEN_COMMA if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='5' + arg1: CONST Int type=kotlin.Int value='1' then: CONST Boolean type=kotlin.Boolean value='true' else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='6' + arg1: CONST Int type=kotlin.Int value='2' then: CONST Boolean type=kotlin.Boolean value='true' else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='7' - then: CONST String type=kotlin.String value='567' + arg1: CONST Int type=kotlin.Int value='3' + then: CONST Boolean type=kotlin.Boolean value='true' + else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null + arg1: CONST Int type=kotlin.Int value='4' + then: CONST String type=kotlin.String value='1234' + if: WHEN type=kotlin.Boolean operator=WHEN_COMMA if: WHEN type=kotlin.Boolean operator=WHEN_COMMA if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='8' + arg1: CONST Int type=kotlin.Int value='5' then: CONST Boolean type=kotlin.Boolean value='true' else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null - arg1: CONST Int type=kotlin.Int value='9' - then: CONST String type=kotlin.String value='89' - else: CONST String type=kotlin.String value='?' + arg1: CONST Int type=kotlin.Int value='6' + then: CONST Boolean type=kotlin.Boolean value='true' + else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null + arg1: CONST Int type=kotlin.Int value='7' + then: CONST String type=kotlin.String value='567' + if: WHEN type=kotlin.Boolean operator=WHEN_COMMA + if: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null + arg1: CONST Int type=kotlin.Int value='8' + then: CONST Boolean type=kotlin.Boolean value='true' + else: CALL .EQEQ type=kotlin.Boolean operator=EQEQ + arg0: GET_VAR tmp0_subject type=kotlin.Int operator=null + arg1: CONST Int type=kotlin.Int value='9' + then: CONST String type=kotlin.String value='89' + else: CONST String type=kotlin.String value='?' diff --git a/compiler/testData/ir/irText/whileDoWhile.txt b/compiler/testData/ir/irText/whileDoWhile.txt index 2ea8fba66c4..3ced1f94aa3 100644 --- a/compiler/testData/ir/irText/whileDoWhile.txt +++ b/compiler/testData/ir/irText/whileDoWhile.txt @@ -1,73 +1,71 @@ -IrFile /whileDoWhile.kt - IrFunction public fun test(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR var x: kotlin.Int - CONST Int type=kotlin.Int value='0' - WHILE label=null operator=WHILE_LOOP - condition: CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR x type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='5' - body: BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp0: kotlin.Int +FILE /whileDoWhile.kt + FUN public fun test(): kotlin.Unit + BLOCK_BODY + VAR var x: kotlin.Int + CONST Int type=kotlin.Int value='0' + WHILE label=null operator=WHILE_LOOP + condition: CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR x type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='5' + body: BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp0: kotlin.Int + GET_VAR x type=kotlin.Int operator=POSTFIX_INCR + SET_VAR x type= operator=POSTFIX_INCR + CALL .inc type=kotlin.Int operator=POSTFIX_INCR + $this: GET_VAR tmp0 type=kotlin.Int operator=null + GET_VAR tmp0 type=kotlin.Int operator=null + WHILE label=null operator=WHILE_LOOP + condition: CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR x type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='10' + body: BLOCK type=kotlin.Int operator=null + BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp1: kotlin.Int GET_VAR x type=kotlin.Int operator=POSTFIX_INCR SET_VAR x type= operator=POSTFIX_INCR CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp0 type=kotlin.Int operator=null - GET_VAR tmp0 type=kotlin.Int operator=null - WHILE label=null operator=WHILE_LOOP - condition: CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR x type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='10' - body: BLOCK type=kotlin.Int hasResult=true operator=null - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp1: kotlin.Int - GET_VAR x type=kotlin.Int operator=POSTFIX_INCR - SET_VAR x type= operator=POSTFIX_INCR - CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp1 type=kotlin.Int operator=null - GET_VAR tmp1 type=kotlin.Int operator=null - DO_WHILE label=null operator=DO_WHILE_LOOP - body: BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp2: kotlin.Int + $this: GET_VAR tmp1 type=kotlin.Int operator=null + GET_VAR tmp1 type=kotlin.Int operator=null + DO_WHILE label=null operator=DO_WHILE_LOOP + body: BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp2: kotlin.Int + GET_VAR x type=kotlin.Int operator=POSTFIX_INCR + SET_VAR x type= operator=POSTFIX_INCR + CALL .inc type=kotlin.Int operator=POSTFIX_INCR + $this: GET_VAR tmp2 type=kotlin.Int operator=null + GET_VAR tmp2 type=kotlin.Int operator=null + condition: CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR x type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='15' + DO_WHILE label=null operator=DO_WHILE_LOOP + body: BLOCK type=kotlin.Unit operator=null + BLOCK type=kotlin.Int operator=POSTFIX_INCR + VAR val tmp3: kotlin.Int GET_VAR x type=kotlin.Int operator=POSTFIX_INCR SET_VAR x type= operator=POSTFIX_INCR CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp2 type=kotlin.Int operator=null - GET_VAR tmp2 type=kotlin.Int operator=null - condition: CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR x type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='15' - DO_WHILE label=null operator=DO_WHILE_LOOP - body: BLOCK type=kotlin.Int hasResult=true operator=null - BLOCK type=kotlin.Int hasResult=true operator=POSTFIX_INCR - VAR val tmp3: kotlin.Int - GET_VAR x type=kotlin.Int operator=POSTFIX_INCR - SET_VAR x type= operator=POSTFIX_INCR - CALL .inc type=kotlin.Int operator=POSTFIX_INCR - $this: GET_VAR tmp3 type=kotlin.Int operator=null - GET_VAR tmp3 type=kotlin.Int operator=null - condition: CALL .LT0 type=kotlin.Boolean operator=LT - arg0: CALL .compareTo type=kotlin.Int operator=LT - $this: GET_VAR x type=kotlin.Int operator=null - other: CONST Int type=kotlin.Int value='20' - IrFunction public fun testSmartcastInCondition(): kotlin.Unit - IrExpressionBody - BLOCK type= hasResult=false operator=null - VAR val a: kotlin.Any? = null - CONST Null type=kotlin.Nothing? value='null' - WHEN type=kotlin.Unit operator=IF - if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.Boolean - GET_VAR a type=kotlin.Any? operator=null - then: BLOCK type= hasResult=false operator=null - WHILE label=null operator=WHILE_LOOP - condition: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Boolean - GET_VAR a type=kotlin.Any? operator=null - body: BLOCK type= hasResult=false operator=null - DO_WHILE label=null operator=DO_WHILE_LOOP - body: BLOCK type= hasResult=false operator=null - condition: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Boolean - GET_VAR a type=kotlin.Any? operator=null + $this: GET_VAR tmp3 type=kotlin.Int operator=null + GET_VAR tmp3 type=kotlin.Int operator=null + condition: CALL .LT0 type=kotlin.Boolean operator=LT + arg0: CALL .compareTo type=kotlin.Int operator=LT + $this: GET_VAR x type=kotlin.Int operator=null + other: CONST Int type=kotlin.Int value='20' + FUN public fun testSmartcastInCondition(): kotlin.Unit + BLOCK_BODY + VAR val a: kotlin.Any? = null + CONST Null type=kotlin.Nothing? value='null' + WHEN type=kotlin.Unit operator=IF + if: TYPE_OP operator=INSTANCEOF typeOperand=kotlin.Boolean + GET_VAR a type=kotlin.Any? operator=null + then: BLOCK type=kotlin.Unit operator=null + WHILE label=null operator=WHILE_LOOP + condition: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Boolean + GET_VAR a type=kotlin.Any? operator=null + body: BLOCK type=kotlin.Unit operator=null + DO_WHILE label=null operator=DO_WHILE_LOOP + body: BLOCK type=kotlin.Unit operator=null + condition: TYPE_OP operator=IMPLICIT_CAST typeOperand=kotlin.Boolean + GET_VAR a type=kotlin.Any? operator=null diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 987bb7c8003..3ccc019e7f5 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -281,6 +281,12 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { doTest(fileName); } + @TestMetadata("tryCatchWithImplicitCast.kt") + public void testTryCatchWithImplicitCast() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/tryCatchWithImplicitCast.kt"); + doTest(fileName); + } + @TestMetadata("typeOperators.kt") public void testTypeOperators() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/ir/irText/typeOperators.kt");