From 8551bcf10362bffcf256e9542d032fb3805a5309 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Wed, 21 Sep 2016 15:32:36 +0300 Subject: [PATCH] Refactor IrWhen. --- .../kotlin/backend/jvm/ExpressionCodegen.kt | 8 +- .../BranchingExpressionGenerator.kt | 46 +++-- .../transformations/InsertImplicitCasts.kt | 11 +- .../jetbrains/kotlin/ir/expressions/IrWhen.kt | 24 ++- .../ir/expressions/impl/IrIfThenElseImpl.kt | 65 +------ .../kotlin/ir/expressions/impl/IrWhenImpl.kt | 73 +++---- .../jetbrains/kotlin/ir/util/DumpIrTree.kt | 13 +- .../kotlin/ir/util/RenderIrElement.kt | 3 + .../ir/visitors/IrElementTransformer.kt | 7 + .../kotlin/ir/visitors/IrElementVisitor.kt | 1 + .../ir/visitors/IrElementVisitorVoid.kt | 3 + .../ir/irText/classes/dataClasses.txt | 71 +++---- .../ir/irText/expressions/bangbang.txt | 41 ++-- .../irText/expressions/booleanOperators.txt | 18 +- .../expressions/breakContinueInLoopHeader.txt | 52 +++-- .../irText/expressions/chainOfSafeCalls.txt | 60 +++--- .../ir/irText/expressions/coercionToUnit.txt | 38 ++-- .../ir/irText/expressions/dotQualified.txt | 15 +- .../testData/ir/irText/expressions/elvis.txt | 91 +++++---- .../ir/irText/expressions/ifElseIf.txt | 26 +-- .../expressions/jvmStaticFieldReference.txt | 14 +- .../ir/irText/expressions/safeAssignment.txt | 19 +- .../safeCallWithIncrementDecrement.txt | 65 ++++--- .../ir/irText/expressions/safeCalls.txt | 83 ++++---- .../expressions/setFieldWithImplicitCast.txt | 17 +- .../ir/irText/expressions/smartCasts.txt | 31 +-- .../smartCastsWithDestructuring.txt | 9 +- .../testData/ir/irText/expressions/throw.txt | 15 +- .../expressions/tryCatchWithImplicitCast.txt | 9 +- .../ir/irText/expressions/typeArguments.txt | 15 +- .../expressions/varargWithImplicitCast.txt | 22 ++- .../expressions/variableAsFunctionCall.txt | 30 +-- .../testData/ir/irText/expressions/when.txt | 183 +++++++++++------- .../ir/irText/expressions/whenElse.txt | 4 +- .../ir/irText/expressions/whileDoWhile.txt | 25 +-- .../ir/irText/lambdas/nonLocalReturn.txt | 22 ++- .../ir/irText/regressions/coercionInLoop.txt | 25 +-- 37 files changed, 700 insertions(+), 554 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ExpressionCodegen.kt index 430fa2a8bd6..bb65d283dea 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ExpressionCodegen.kt @@ -30,8 +30,6 @@ import org.jetbrains.kotlin.ir.declarations.IrVariable import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.IrIfThenElseImpl import org.jetbrains.kotlin.ir.visitors.IrElementVisitor -import org.jetbrains.kotlin.psi.KtCallExpression -import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.AsmTypes import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE import org.jetbrains.kotlin.types.KotlinType @@ -303,13 +301,13 @@ class ExpressionCodegen( /*TODO */ if (expression is IrIfThenElseImpl) { val elseLabel = Label() - val condition = expression.getNthCondition(0)!! + val condition = expression.branches[0].condition gen(condition, data) BranchedValue.condJump(StackValue.onStack(condition.asmType), elseLabel, true, mv) val end = Label() - expression.getNthResult(0)!!.apply { + expression.branches[0].result.apply { gen(this, data) coerceNotToUnit(this.asmType, expression.asmType) } @@ -317,7 +315,7 @@ class ExpressionCodegen( mv.goTo(end) mv.mark(elseLabel) - expression.getNthResult(1)?.apply { + expression.branches.getOrNull(1)?.result?.apply { gen(this, data) coerceNotToUnit(this.asmType, expression.asmType) } 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 bf143fd382a..85138f1dbaa 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 @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.psi2ir.defaultLoad import org.jetbrains.kotlin.psi2ir.deparenthesize import org.jetbrains.kotlin.resolve.BindingContext +import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.utils.SmartList class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : StatementGeneratorExtension(statementGenerator) { @@ -32,13 +33,13 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta val resultType = getInferredTypeWithImplicitCastsOrFail(expression) var ktLastIf: KtIfExpression = expression - val irBranches = SmartList>() + val irBranches = SmartList() var irElseBranch: IrExpression? = null whenBranches@while (true) { val irCondition = statementGenerator.generateExpression(ktLastIf.condition!!) val irThenBranch = statementGenerator.generateExpression(ktLastIf.then!!) - irBranches.add(Pair(irCondition, irThenBranch)) + irBranches.add(IrBranchImpl(irCondition, irThenBranch)) val ktElse = ktLastIf.`else`?.deparenthesize() when (ktElse) { @@ -52,19 +53,29 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta } } - return if (irBranches.size == 1) { - val (irCondition, irThenBranch) = irBranches[0] - IrIfThenElseImpl(expression.startOffset, expression.endOffset, resultType, - irCondition, irThenBranch, irElseBranch, IrStatementOrigin.IF) + return createIrWhen(expression, irBranches, irElseBranch, resultType) + } + + private fun createIrWhen( + ktIf: KtIfExpression, + irBranches: List, + irElseResult: IrExpression?, + resultType: KotlinType + ): IrWhen { + if (irBranches.size == 1) { + return IrIfThenElseImpl(ktIf.startOffset, ktIf.endOffset, resultType, + irBranches[0].condition, irBranches[0].result, irElseResult) } - else { - val irWhen = IrWhenImpl(expression.startOffset, expression.endOffset, resultType, IrStatementOrigin.WHEN) - for ((irCondition, irThenBranch) in irBranches) { - irWhen.addBranch(irCondition, irThenBranch) - } - irWhen.elseBranch = irElseBranch - irWhen + + val irWhen = IrWhenImpl(ktIf.startOffset, ktIf.endOffset, resultType, IrStatementOrigin.WHEN) + + irWhen.branches.addAll(irBranches) + + irElseResult?.let { + irWhen.branches.add(IrBranchImpl.elseBranch(it)) } + + return irWhen } fun generateWhenExpression(expression: KtWhenExpression): IrExpression { @@ -78,7 +89,8 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta for (ktEntry in expression.entries) { if (ktEntry.isElse) { - irWhen.elseBranch = statementGenerator.generateExpression(ktEntry.expression!!) + val irElseResult = statementGenerator.generateExpression(ktEntry.expression!!) + irWhen.branches.add(IrBranchImpl.elseBranch(irElseResult)) break } @@ -94,7 +106,7 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta } val irBranchResult = statementGenerator.generateExpression(ktEntry.expression!!) - irWhen.addBranch(irBranchCondition!!, irBranchResult) + irWhen.branches.add(IrBranchImpl(irBranchCondition!!, irBranchResult)) } return generateWhenBody(expression, irSubject, irWhen) @@ -102,13 +114,13 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta private fun generateWhenBody(expression: KtWhenExpression, irSubject: IrVariable?, irWhen: IrWhen): IrExpression { if (irSubject == null) { - if (irWhen.branchesCount == 0 && irWhen.elseBranch == null) + if (irWhen.branches.isEmpty()) return IrBlockImpl(expression.startOffset, expression.endOffset, context.builtIns.unitType, IrStatementOrigin.WHEN) else return irWhen } else { - if (irWhen.branchesCount == 0) { + if (irWhen.branches.isEmpty()) { val irBlock = IrBlockImpl(expression.startOffset, expression.endOffset, context.builtIns.unitType, IrStatementOrigin.WHEN) irBlock.statements.add(irSubject) return irBlock diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt index 581ae9f69ac..ce44ae45899 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/transformations/InsertImplicitCasts.kt @@ -127,16 +127,11 @@ class InsertImplicitCasts(val builtIns: KotlinBuiltIns): IrElementTransformerVoi val resultType = expression.type - for (i in expression.branchIndices) { - val nthCondition = expression.getNthCondition(i)!! - val nthResult = expression.getNthResult(i)!! - - expression.putNthCondition(i, nthCondition.cast(builtIns.booleanType)) - expression.putNthResult(i, nthResult.cast(resultType)) + for (irBranch in expression.branches) { + irBranch.condition = irBranch.condition.cast(builtIns.booleanType) + irBranch.result = irBranch.result.cast(resultType) } - expression.elseBranch = expression.elseBranch?.cast(resultType) - return expression } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrWhen.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrWhen.kt index 57611b290c2..ebfd0e0e38c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrWhen.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrWhen.kt @@ -16,19 +16,23 @@ package org.jetbrains.kotlin.ir.expressions +import org.jetbrains.kotlin.ir.IrElement +import org.jetbrains.kotlin.ir.visitors.IrElementTransformer +import org.jetbrains.kotlin.ir.visitors.IrElementVisitor + interface IrWhen : IrExpression { val origin: IrStatementOrigin? - val branchesCount: Int - - fun getNthCondition(n: Int): IrExpression? - fun getNthResult(n: Int): IrExpression? - - fun putNthCondition(n: Int, expression: IrExpression) - fun putNthResult(n: Int, expression: IrExpression) - - var elseBranch: IrExpression? + val branches: MutableList } -val IrWhen.branchIndices: IntRange get() = 0 ..branchesCount - 1 +interface IrBranch : IrElement { + var condition: IrExpression + var result: IrExpression + override fun transform(transformer: IrElementTransformer, data: D): IrBranch = + transformer.visitBranch(this, data) + + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitBranch(this, data) +} diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt index 2da89d1f8d4..f1fdd60d762 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt @@ -16,17 +16,19 @@ package org.jetbrains.kotlin.ir.expressions.impl +import org.jetbrains.kotlin.ir.expressions.IrBranch import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.IrWhen -import org.jetbrains.kotlin.ir.visitors.IrElementTransformer -import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.typeUtil.builtIns +import org.jetbrains.kotlin.utils.SmartList class IrIfThenElseImpl( startOffset: Int, endOffset: Int, type: KotlinType, override val origin: IrStatementOrigin? = null -) : IrExpressionBase(startOffset, endOffset, type), IrWhen { +) : IrWhenBase(startOffset, endOffset, type) { + override val branches: MutableList = SmartList() + constructor( startOffset: Int, endOffset: Int, type: KotlinType, condition: IrExpression, @@ -34,56 +36,9 @@ class IrIfThenElseImpl( elseBranch: IrExpression? = null, origin: IrStatementOrigin? = null ) : this(startOffset, endOffset, type, origin) { - this.condition = condition - this.thenBranch = thenBranch - this.elseBranch = elseBranch - } - - override val branchesCount: Int get() = 1 - - override fun getNthCondition(n: Int): IrExpression? = - if (n == 0) condition else null - - override fun getNthResult(n: Int): IrExpression? = - when (n) { - 0 -> { - thenBranch - } - 1 -> { - elseBranch - } - else -> null - } - - - override fun putNthCondition(n: Int, expression: IrExpression) { - if (n == 0) condition = expression - else throw AssertionError("No such branch $n") - } - - override fun putNthResult(n: Int, expression: IrExpression) { - if (n == 0) thenBranch = expression - else throw AssertionError("No such branch $n") - } - - lateinit var condition: IrExpression - - lateinit var thenBranch: IrExpression - - override var elseBranch: IrExpression? = null - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitWhen(this, data) - - override fun acceptChildren(visitor: IrElementVisitor, data: D) { - condition.accept(visitor, data) - thenBranch.accept(visitor, data) - elseBranch?.accept(visitor, data) - } - - override fun transformChildren(transformer: IrElementTransformer, data: D) { - condition = condition.transform(transformer, data) - thenBranch = thenBranch.transform(transformer, data) - elseBranch = elseBranch?.transform(transformer, data) + branches.add(IrBranchImpl(startOffset, endOffset, condition, thenBranch)) + if (elseBranch != null) { + branches.add(IrBranchImpl.elseBranch(elseBranch)) + } } } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt index da70a5f4f9d..9c1827eb7df 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt @@ -16,57 +16,58 @@ package org.jetbrains.kotlin.ir.expressions.impl -import org.jetbrains.kotlin.ir.expressions.IrExpression -import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin -import org.jetbrains.kotlin.ir.expressions.IrWhen +import org.jetbrains.kotlin.ir.IrElementBase +import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.visitors.IrElementTransformer import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.typeUtil.builtIns import java.util.* +abstract class IrWhenBase(startOffset: Int, endOffset: Int, type: KotlinType, override val origin: IrStatementOrigin? = null) : + IrExpressionBase(startOffset, endOffset, type), IrWhen { + override fun accept(visitor: IrElementVisitor, data: D): R = + visitor.visitWhen(this, data) + + override fun acceptChildren(visitor: IrElementVisitor, data: D) { + branches.forEach { it.accept(visitor, data) } + } + + override fun transformChildren(transformer: IrElementTransformer, data: D) { + branches.forEachIndexed { i, irBranch -> + branches[i] = irBranch.transform(transformer, data) + } + } +} + class IrWhenImpl( startOffset: Int, endOffset: Int, type: KotlinType, override val origin: IrStatementOrigin? = null -) : IrExpressionBase(startOffset, endOffset, type), IrWhen { - private val branchParts = ArrayList() +) : IrWhenBase(startOffset, endOffset, type) { + override val branches: MutableList = ArrayList() +} - fun addBranch(condition: IrExpression, result: IrExpression) { - branchParts.add(condition) - branchParts.add(result) - } - - override var elseBranch: IrExpression? = null - - override val branchesCount: Int get() = branchParts.size / 2 - - override fun getNthCondition(n: Int): IrExpression? = - branchParts.getOrNull(n * 2) - - override fun getNthResult(n: Int): IrExpression? = - branchParts.getOrNull(n * 2 + 1) - - override fun putNthCondition(n: Int, expression: IrExpression) { - branchParts[n * 2] = expression - } - - override fun putNthResult(n: Int, expression: IrExpression) { - branchParts[n * 2 + 1] = expression - } - - override fun accept(visitor: IrElementVisitor, data: D): R = - visitor.visitWhen(this, data) +class IrBranchImpl(startOffset: Int, endOffset: Int, override var condition: IrExpression, override var result: IrExpression) : + IrElementBase(startOffset, endOffset), IrBranch { + constructor(condition: IrExpression, result: IrExpression) : this(condition.startOffset, condition.endOffset, condition, result) override fun acceptChildren(visitor: IrElementVisitor, data: D) { - branchParts.forEach { it.accept(visitor, data) } - elseBranch?.accept(visitor, data) + condition.accept(visitor, data) + result.accept(visitor, data) } override fun transformChildren(transformer: IrElementTransformer, data: D) { - branchParts.forEachIndexed { i, irExpression -> - branchParts[i] = irExpression.transform(transformer, data) - } - elseBranch = elseBranch?.transform(transformer, data) + condition = condition.transform(transformer, data) + result = result.transform(transformer, data) + } + + companion object { + fun elseBranch(result: IrExpression) = + IrBranchImpl( + IrConstImpl.boolean(result.startOffset, result.endOffset, result.type.builtIns.booleanType, true), + result + ) } } \ No newline at end of file diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt index 55578a168e8..d445c422beb 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DumpIrTree.kt @@ -131,11 +131,16 @@ class DumpIrTreeVisitor(out: Appendable): IrElementVisitor { override fun visitWhen(expression: IrWhen, data: String) { expression.dumpLabeledElementWith(data) { - for (i in 0 .. expression.branchesCount - 1) { - expression.getNthCondition(i)!!.accept(this, "if") - expression.getNthResult(i)!!.accept(this, "then") + expression.branches.forEach { + it.accept(this, "") } - expression.elseBranch?.accept(this, "else") + } + } + + override fun visitBranch(branch: IrBranch, data: String) { + branch.dumpLabeledElementWith(data) { + branch.condition.accept(this, "if") + branch.result.accept(this, "then") } } 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 c48f02aca2c..77e8de6c4cc 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 @@ -155,6 +155,9 @@ class RenderIrElementVisitor : IrElementVisitor { override fun visitWhen(expression: IrWhen, data: Nothing?): String = "WHEN type=${expression.type.render()} origin=${expression.origin}" + override fun visitBranch(branch: IrBranch, data: Nothing?): String = + "BRANCH" + override fun visitWhileLoop(loop: IrWhileLoop, data: Nothing?): String = "WHILE label=${loop.label} origin=${loop.origin}" diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementTransformer.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementTransformer.kt index 2fd047a3927..f85242044d5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementTransformer.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementTransformer.kt @@ -92,6 +92,13 @@ interface IrElementTransformer : IrElementVisitor { override fun visitTypeOperator(expression: IrTypeOperatorCall, data: D) = visitExpression(expression, data) override fun visitWhen(expression: IrWhen, data: D) = visitExpression(expression, data) + + override fun visitBranch(branch: IrBranch, data: D): IrBranch = + branch.apply { + condition = condition.transform(this@IrElementTransformer, data) + result = result.transform(this@IrElementTransformer, data) + } + override fun visitLoop(loop: IrLoop, data: D) = visitExpression(loop, data) override fun visitWhileLoop(loop: IrWhileLoop, data: D) = visitLoop(loop, data) override fun visitDoWhileLoop(loop: IrDoWhileLoop, data: D) = visitLoop(loop, data) 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 6d9280b6ca0..dddde726575 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 @@ -78,6 +78,7 @@ interface IrElementVisitor { fun visitTypeOperator(expression: IrTypeOperatorCall, data: D) = visitExpression(expression, data) fun visitWhen(expression: IrWhen, data: D) = visitExpression(expression, data) + fun visitBranch(branch: IrBranch, data: D) = visitElement(branch, data) fun visitLoop(loop: IrLoop, data: D) = visitExpression(loop, data) fun visitWhileLoop(loop: IrWhileLoop, data: D) = visitLoop(loop, data) fun visitDoWhileLoop(loop: IrDoWhileLoop, data: D) = visitLoop(loop, data) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementVisitorVoid.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementVisitorVoid.kt index 133fe745693..067be3ca8a3 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementVisitorVoid.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/visitors/IrElementVisitorVoid.kt @@ -165,6 +165,9 @@ interface IrElementVisitorVoid : IrElementVisitor { fun visitWhen(expression: IrWhen) = visitExpression(expression) override fun visitWhen(expression: IrWhen, data: Nothing?) = visitWhen(expression) + fun visitBranch(branch: IrBranch) = visitElement(branch) + override fun visitBranch(branch: IrBranch, data: Nothing?) = visitBranch(branch) + fun visitLoop(loop: IrLoop) = visitExpression(loop) override fun visitLoop(loop: IrLoop, data: Nothing?) = visitLoop(loop) diff --git a/compiler/testData/ir/irText/classes/dataClasses.txt b/compiler/testData/ir/irText/classes/dataClasses.txt index 040e380c4dd..c266bf50e46 100644 --- a/compiler/testData/ir/irText/classes/dataClasses.txt +++ b/compiler/testData/ir/irText/classes/dataClasses.txt @@ -99,45 +99,50 @@ FILE /dataClasses.kt FUN GENERATED_DATA_CLASS_MEMBER public open override fun equals(other: kotlin.Any?): kotlin.Boolean BLOCK_BODY WHEN type=kotlin.Unit origin=null - if: CALL 'EQEQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQEQ - arg0: THIS of 'Test1' type=Test1 - arg1: GET_VAR 'value-parameter other: Any?' type=kotlin.Any? origin=null - then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' - CONST Boolean type=kotlin.Boolean value='true' + BRANCH + if: CALL 'EQEQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQEQ + arg0: THIS of 'Test1' type=Test1 + arg1: GET_VAR 'value-parameter other: Any?' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' + CONST Boolean type=kotlin.Boolean value='true' WHEN type=kotlin.Unit origin=null - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=Test1 - GET_VAR 'value-parameter other: Any?' type=kotlin.Any? origin=null - then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' - CONST Boolean type=kotlin.Boolean value='false' + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=Test1 + GET_VAR 'value-parameter other: Any?' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' + CONST Boolean type=kotlin.Boolean value='false' VAR IR_TEMPORARY_VARIABLE val tmp0_other_with_cast: Test1 TYPE_OP origin=CAST typeOperand=Test1 GET_VAR 'value-parameter other: Any?' type=kotlin.Any? origin=null WHEN type=kotlin.Unit origin=null - if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY - $this: THIS of 'Test1' type=Test1 - arg1: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'tmp0_other_with_cast: Test1' type=Test1 origin=null - then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' - CONST Boolean type=kotlin.Boolean value='false' + BRANCH + if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY + $this: THIS of 'Test1' type=Test1 + arg1: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'tmp0_other_with_cast: Test1' type=Test1 origin=null + then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' + CONST Boolean type=kotlin.Boolean value='false' WHEN type=kotlin.Unit origin=null - if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL '(): String' type=kotlin.String origin=GET_PROPERTY - $this: THIS of 'Test1' type=Test1 - arg1: CALL '(): String' type=kotlin.String origin=GET_PROPERTY - $this: GET_VAR 'tmp0_other_with_cast: Test1' type=Test1 origin=null - then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' - CONST Boolean type=kotlin.Boolean value='false' + BRANCH + if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL '(): String' type=kotlin.String origin=GET_PROPERTY + $this: THIS of 'Test1' type=Test1 + arg1: CALL '(): String' type=kotlin.String origin=GET_PROPERTY + $this: GET_VAR 'tmp0_other_with_cast: Test1' type=Test1 origin=null + then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' + CONST Boolean type=kotlin.Boolean value='false' WHEN type=kotlin.Unit origin=null - if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL '(): Any' type=kotlin.Any origin=GET_PROPERTY - $this: THIS of 'Test1' type=Test1 - arg1: CALL '(): Any' type=kotlin.Any origin=GET_PROPERTY - $this: GET_VAR 'tmp0_other_with_cast: Test1' type=Test1 origin=null - then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' - CONST Boolean type=kotlin.Boolean value='false' + BRANCH + if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL '(): Any' type=kotlin.Any origin=GET_PROPERTY + $this: THIS of 'Test1' type=Test1 + arg1: CALL '(): Any' type=kotlin.Any origin=GET_PROPERTY + $this: GET_VAR 'tmp0_other_with_cast: Test1' type=Test1 origin=null + then: RETURN type=kotlin.Nothing from='equals(Any?): Boolean' + CONST Boolean type=kotlin.Boolean value='false' RETURN type=kotlin.Nothing from='equals(Any?): Boolean' CONST Boolean type=kotlin.Boolean value='true' diff --git a/compiler/testData/ir/irText/expressions/bangbang.txt b/compiler/testData/ir/irText/expressions/bangbang.txt index df1e0f6bf49..c40f06db4de 100644 --- a/compiler/testData/ir/irText/expressions/bangbang.txt +++ b/compiler/testData/ir/irText/expressions/bangbang.txt @@ -6,11 +6,14 @@ FILE /bangbang.kt VAR IR_TEMPORARY_VARIABLE val tmp0_notnull: kotlin.Any? GET_VAR 'value-parameter a: Any?' type=kotlin.Any? origin=null WHEN type=kotlin.Any origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_notnull: Any?' type=kotlin.Any? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CALL 'THROW_NPE(): Nothing' type=kotlin.Nothing origin=EXCLEXCL - else: GET_VAR 'tmp0_notnull: Any?' type=kotlin.Any? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_notnull: Any?' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CALL 'THROW_NPE(): Nothing' type=kotlin.Nothing origin=EXCLEXCL + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_notnull: Any?' type=kotlin.Any? origin=null FUN public fun test2(a: kotlin.Any?): kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='test2(Any?): Int' @@ -20,15 +23,21 @@ FILE /bangbang.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.Any? GET_VAR 'value-parameter a: Any?' type=kotlin.Any? origin=null WHEN type=kotlin.Int? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: Any?' type=kotlin.Any? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'hashCode(): Int' type=kotlin.Int origin=null - $this: GET_VAR 'tmp0_safe_receiver: Any?' type=kotlin.Any? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: Any?' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'hashCode(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'tmp0_safe_receiver: Any?' type=kotlin.Any? origin=null WHEN type=kotlin.Int origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp1_notnull: Int?' type=kotlin.Int? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CALL 'THROW_NPE(): Nothing' type=kotlin.Nothing origin=EXCLEXCL - else: GET_VAR 'tmp1_notnull: Int?' type=kotlin.Int? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp1_notnull: Int?' type=kotlin.Int? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CALL 'THROW_NPE(): Nothing' type=kotlin.Nothing origin=EXCLEXCL + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp1_notnull: Int?' type=kotlin.Int? origin=null diff --git a/compiler/testData/ir/irText/expressions/booleanOperators.txt b/compiler/testData/ir/irText/expressions/booleanOperators.txt index 40cb7fe8e3f..56cd31a3894 100644 --- a/compiler/testData/ir/irText/expressions/booleanOperators.txt +++ b/compiler/testData/ir/irText/expressions/booleanOperators.txt @@ -3,16 +3,22 @@ FILE /booleanOperators.kt BLOCK_BODY RETURN type=kotlin.Nothing from='test1(Boolean, Boolean): Boolean' WHEN type=kotlin.Boolean origin=ANDAND - if: GET_VAR 'value-parameter a: Boolean' type=kotlin.Boolean origin=null - then: GET_VAR 'value-parameter b: Boolean' type=kotlin.Boolean origin=null - else: CONST Boolean type=kotlin.Boolean value='false' + BRANCH + if: GET_VAR 'value-parameter a: Boolean' type=kotlin.Boolean origin=null + then: GET_VAR 'value-parameter b: Boolean' type=kotlin.Boolean origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CONST Boolean type=kotlin.Boolean value='false' FUN public fun test2(a: kotlin.Boolean, b: kotlin.Boolean): kotlin.Boolean BLOCK_BODY RETURN type=kotlin.Nothing from='test2(Boolean, Boolean): Boolean' WHEN type=kotlin.Boolean origin=OROR - if: GET_VAR 'value-parameter a: Boolean' type=kotlin.Boolean origin=null - then: CONST Boolean type=kotlin.Boolean value='true' - else: GET_VAR 'value-parameter b: Boolean' type=kotlin.Boolean origin=null + BRANCH + if: GET_VAR 'value-parameter a: Boolean' type=kotlin.Boolean origin=null + then: CONST Boolean type=kotlin.Boolean value='true' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'value-parameter b: Boolean' type=kotlin.Boolean origin=null FUN public fun test1x(a: kotlin.Boolean, b: kotlin.Boolean): kotlin.Boolean BLOCK_BODY RETURN type=kotlin.Nothing from='test1x(Boolean, Boolean): Boolean' diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.txt index 6f6c4edf929..368cfc6bd79 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.txt @@ -9,11 +9,14 @@ FILE /breakContinueInLoopHeader.kt VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.Boolean? GET_VAR 'value-parameter c: Boolean?' type=kotlin.Boolean? origin=null WHEN type=kotlin.Boolean origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: Boolean?' type=kotlin.Boolean? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: BREAK label=null loop.label=L - else: GET_VAR 'tmp0_elvis_lhs: Boolean?' type=kotlin.Boolean? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: Boolean?' type=kotlin.Boolean? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: BREAK label=null loop.label=L + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_elvis_lhs: Boolean?' type=kotlin.Boolean? origin=null FUN public fun test2(c: kotlin.Boolean?): kotlin.Unit BLOCK_BODY WHILE label=L origin=WHILE_LOOP @@ -24,11 +27,14 @@ FILE /breakContinueInLoopHeader.kt VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.Boolean? GET_VAR 'value-parameter c: Boolean?' type=kotlin.Boolean? origin=null WHEN type=kotlin.Boolean origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: Boolean?' type=kotlin.Boolean? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONTINUE label=null loop.label=L - else: GET_VAR 'tmp0_elvis_lhs: Boolean?' type=kotlin.Boolean? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: Boolean?' type=kotlin.Boolean? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONTINUE label=null loop.label=L + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_elvis_lhs: Boolean?' type=kotlin.Boolean? origin=null FUN public fun test3(ss: kotlin.collections.List?): kotlin.Unit BLOCK_BODY WHILE label=L origin=WHILE_LOOP @@ -41,11 +47,14 @@ FILE /breakContinueInLoopHeader.kt VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.collections.List? GET_VAR 'value-parameter ss: List?' type=kotlin.collections.List? origin=null WHEN type=kotlin.collections.List origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: List?' type=kotlin.collections.List? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONTINUE label=null loop.label=L - else: GET_VAR 'tmp0_elvis_lhs: List?' type=kotlin.collections.List? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: List?' type=kotlin.collections.List? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONTINUE label=null loop.label=L + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_elvis_lhs: List?' type=kotlin.collections.List? origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'hasNext(): Boolean' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT $this: GET_VAR 'tmp1_iterator: Iterator' type=kotlin.collections.Iterator origin=null @@ -65,11 +74,14 @@ FILE /breakContinueInLoopHeader.kt VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.collections.List? GET_VAR 'value-parameter ss: List?' type=kotlin.collections.List? origin=null WHEN type=kotlin.collections.List origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: List?' type=kotlin.collections.List? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: BREAK label=null loop.label=L - else: GET_VAR 'tmp0_elvis_lhs: List?' type=kotlin.collections.List? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: List?' type=kotlin.collections.List? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: BREAK label=null loop.label=L + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_elvis_lhs: List?' type=kotlin.collections.List? origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'hasNext(): Boolean' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT $this: GET_VAR 'tmp1_iterator: Iterator' type=kotlin.collections.Iterator origin=null diff --git a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt index 0be40ad52d2..6843b012082 100644 --- a/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt +++ b/compiler/testData/ir/irText/expressions/chainOfSafeCalls.txt @@ -25,30 +25,42 @@ FILE /chainOfSafeCalls.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: C? GET_VAR 'value-parameter nc: C?' type=C? origin=null WHEN type=C? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'foo(): C' type=C origin=null - $this: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'foo(): C' type=C origin=null + $this: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null WHEN type=C? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp1_safe_receiver: C?' type=C? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'bar(): C?' type=C? origin=null - $this: GET_VAR 'tmp1_safe_receiver: C?' type=C? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp1_safe_receiver: C?' type=C? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'bar(): C?' type=C? origin=null + $this: GET_VAR 'tmp1_safe_receiver: C?' type=C? origin=null WHEN type=C? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp2_safe_receiver: C?' type=C? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'foo(): C' type=C origin=null - $this: GET_VAR 'tmp2_safe_receiver: C?' type=C? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp2_safe_receiver: C?' type=C? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'foo(): C' type=C origin=null + $this: GET_VAR 'tmp2_safe_receiver: C?' type=C? origin=null WHEN type=C? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp3_safe_receiver: C?' type=C? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'foo(): C' type=C origin=null - $this: GET_VAR 'tmp3_safe_receiver: C?' type=C? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp3_safe_receiver: C?' type=C? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'foo(): C' type=C origin=null + $this: GET_VAR 'tmp3_safe_receiver: C?' type=C? origin=null diff --git a/compiler/testData/ir/irText/expressions/coercionToUnit.txt b/compiler/testData/ir/irText/expressions/coercionToUnit.txt index 49888457a4e..4652d2f293f 100644 --- a/compiler/testData/ir/irText/expressions/coercionToUnit.txt +++ b/compiler/testData/ir/irText/expressions/coercionToUnit.txt @@ -26,24 +26,30 @@ FILE /coercionToUnit.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: java.io.PrintStream! GET_FIELD 'out: PrintStream!' type=java.io.PrintStream! origin=GET_PROPERTY WHEN type=kotlin.Unit? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: PrintStream!' type=java.io.PrintStream! origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'println(String!): Unit' type=kotlin.Unit origin=null - $this: TYPE_OP origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream - GET_VAR 'tmp0_safe_receiver: PrintStream!' type=java.io.PrintStream! origin=null - p0: CONST String type=kotlin.String value='Hello,' + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: PrintStream!' type=java.io.PrintStream! origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'println(String!): Unit' type=kotlin.Unit origin=null + $this: TYPE_OP origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_VAR 'tmp0_safe_receiver: PrintStream!' type=java.io.PrintStream! origin=null + p0: CONST String type=kotlin.String value='Hello,' TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Unit? origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE val tmp1_safe_receiver: java.io.PrintStream! GET_FIELD 'out: PrintStream!' type=java.io.PrintStream! origin=GET_PROPERTY WHEN type=kotlin.Unit? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp1_safe_receiver: PrintStream!' type=java.io.PrintStream! origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'println(String!): Unit' type=kotlin.Unit origin=null - $this: TYPE_OP origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream - GET_VAR 'tmp1_safe_receiver: PrintStream!' type=java.io.PrintStream! origin=null - p0: CONST String type=kotlin.String value='world!' + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp1_safe_receiver: PrintStream!' type=java.io.PrintStream! origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'println(String!): Unit' type=kotlin.Unit origin=null + $this: TYPE_OP origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_VAR 'tmp1_safe_receiver: PrintStream!' type=java.io.PrintStream! origin=null + p0: CONST String type=kotlin.String value='world!' diff --git a/compiler/testData/ir/irText/expressions/dotQualified.txt b/compiler/testData/ir/irText/expressions/dotQualified.txt index 8739a5c4d09..cc1016f8b66 100644 --- a/compiler/testData/ir/irText/expressions/dotQualified.txt +++ b/compiler/testData/ir/irText/expressions/dotQualified.txt @@ -11,9 +11,12 @@ FILE /dotQualified.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.String? GET_VAR 'value-parameter s: String?' type=kotlin.String? origin=null WHEN type=kotlin.Int? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/expressions/elvis.txt b/compiler/testData/ir/irText/expressions/elvis.txt index b3d96113fd5..f0f8fa938cb 100644 --- a/compiler/testData/ir/irText/expressions/elvis.txt +++ b/compiler/testData/ir/irText/expressions/elvis.txt @@ -18,11 +18,14 @@ FILE /elvis.kt VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.Any? GET_VAR 'value-parameter a: Any?' type=kotlin.Any? origin=null WHEN type=kotlin.Any origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: GET_VAR 'value-parameter b: Any' type=kotlin.Any origin=null - else: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: GET_VAR 'value-parameter b: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null FUN public fun test2(a: kotlin.String?, b: kotlin.Any): kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='test2(String?, Any): Any' @@ -30,35 +33,43 @@ FILE /elvis.kt VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.String? GET_VAR 'value-parameter a: String?' type=kotlin.String? origin=null WHEN type=kotlin.Any origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: String?' type=kotlin.String? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: GET_VAR 'value-parameter b: Any' type=kotlin.Any origin=null - else: GET_VAR 'tmp0_elvis_lhs: String?' type=kotlin.String? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: String?' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: GET_VAR 'value-parameter b: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_elvis_lhs: String?' type=kotlin.String? origin=null FUN public fun test3(a: kotlin.Any?, b: kotlin.Any?): kotlin.String BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR 'value-parameter b: Any?' type=kotlin.Any? origin=null - then: RETURN type=kotlin.Nothing from='test3(Any?, Any?): String' - CONST String type=kotlin.String value='' - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String? - GET_VAR 'value-parameter a: Any?' type=kotlin.Any? origin=null - then: RETURN type=kotlin.Nothing from='test3(Any?, Any?): String' - CONST String type=kotlin.String value='' + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR 'value-parameter b: Any?' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='test3(Any?, Any?): String' + CONST String type=kotlin.String value='' + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String? + GET_VAR 'value-parameter a: Any?' type=kotlin.Any? origin=null + then: RETURN type=kotlin.Nothing from='test3(Any?, Any?): String' + CONST String type=kotlin.String value='' RETURN type=kotlin.Nothing from='test3(Any?, Any?): String' BLOCK type=kotlin.String origin=ELVIS VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.Any? GET_VAR 'value-parameter a: Any?' type=kotlin.Any? origin=null WHEN type=kotlin.String origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String - GET_VAR 'value-parameter b: Any?' type=kotlin.Any? origin=null - else: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String - GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR 'value-parameter b: Any?' type=kotlin.Any? origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String + GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null FUN public fun test4(x: kotlin.Any): kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='test4(Any): Any' @@ -66,11 +77,14 @@ FILE /elvis.kt VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.Any? CALL '(): Any?' type=kotlin.Any? origin=GET_PROPERTY WHEN type=kotlin.Any origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null - else: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null FUN public fun test5(x: kotlin.Any): kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='test5(Any): Any' @@ -78,8 +92,11 @@ FILE /elvis.kt VAR IR_TEMPORARY_VARIABLE val tmp0_elvis_lhs: kotlin.Any? CALL 'foo(): Any?' type=kotlin.Any? origin=null WHEN type=kotlin.Any origin=null - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null - else: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: GET_VAR 'tmp0_elvis_lhs: Any?' type=kotlin.Any? origin=null diff --git a/compiler/testData/ir/irText/expressions/ifElseIf.txt b/compiler/testData/ir/irText/expressions/ifElseIf.txt index 7016791e576..6a9ab55a400 100644 --- a/compiler/testData/ir/irText/expressions/ifElseIf.txt +++ b/compiler/testData/ir/irText/expressions/ifElseIf.txt @@ -3,14 +3,18 @@ FILE /ifElseIf.kt BLOCK_BODY RETURN type=kotlin.Nothing from='test(Int): Int' WHEN type=kotlin.Int origin=WHEN - if: CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT - $this: GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value='0' - then: CONST Int type=kotlin.Int value='1' - if: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT - arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT - $this: GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null - other: CONST Int type=kotlin.Int value='0' - then: CONST Int type=kotlin.Int value='-1' - else: CONST Int type=kotlin.Int value='0' + BRANCH + if: CALL 'GT0(Int): Boolean' type=kotlin.Boolean origin=GT + arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=GT + $this: GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value='0' + then: CONST Int type=kotlin.Int value='1' + BRANCH + if: CALL 'LT0(Int): Boolean' type=kotlin.Boolean origin=LT + arg0: CALL 'compareTo(Int): Int' type=kotlin.Int origin=LT + $this: GET_VAR 'value-parameter i: Int' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value='0' + then: CONST Int type=kotlin.Int value='-1' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CONST Int type=kotlin.Int value='0' diff --git a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt index dbcdbaf76c2..b8344ce650b 100644 --- a/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt +++ b/compiler/testData/ir/irText/expressions/jvmStaticFieldReference.txt @@ -29,12 +29,14 @@ FILE /jvmStaticFieldReference.kt FIELD PROPERTY_BACKING_FIELD public final val test: kotlin.Int EXPRESSION_BODY WHEN type=kotlin.Int origin=WHEN - else: BLOCK type=kotlin.Int origin=null - CALL 'println(String!): Unit' type=kotlin.Unit origin=null - $this: TYPE_OP origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream - GET_FIELD 'out: PrintStream!' type=java.io.PrintStream! origin=GET_PROPERTY - p0: CONST String type=kotlin.String value='TestClass/test' - CONST Int type=kotlin.Int value='42' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: BLOCK type=kotlin.Int origin=null + CALL 'println(String!): Unit' type=kotlin.Unit origin=null + $this: TYPE_OP origin=IMPLICIT_NOTNULL typeOperand=java.io.PrintStream + GET_FIELD 'out: PrintStream!' type=java.io.PrintStream! origin=GET_PROPERTY + p0: CONST String type=kotlin.String value='TestClass/test' + CONST Int type=kotlin.Int value='42' FUN DEFAULT_PROPERTY_ACCESSOR public final fun (): kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='(): Int' diff --git a/compiler/testData/ir/irText/expressions/safeAssignment.txt b/compiler/testData/ir/irText/expressions/safeAssignment.txt index d9faed3dce4..3d9580fbf7c 100644 --- a/compiler/testData/ir/irText/expressions/safeAssignment.txt +++ b/compiler/testData/ir/irText/expressions/safeAssignment.txt @@ -24,11 +24,14 @@ FILE /safeAssignment.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: C? GET_VAR 'value-parameter nc: C?' type=C? origin=null WHEN type=kotlin.Unit origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CONST Null type=kotlin.Nothing? value='null' - else: CALL '(Int): Unit' type=kotlin.Unit origin=EQ - $this: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null - : CONST Int type=kotlin.Int value='42' + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL '(Int): Unit' type=kotlin.Unit origin=EQ + $this: GET_VAR 'tmp0_safe_receiver: C?' type=C? origin=null + : CONST Int type=kotlin.Int value='42' diff --git a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt index affce3b3a6d..0c731f5ae27 100644 --- a/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt +++ b/compiler/testData/ir/irText/expressions/safeCallWithIncrementDecrement.txt @@ -18,12 +18,15 @@ FILE /safeCallWithIncrementDecrement.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.Int? $RECEIVER of 'inc() on Int?: Int?' type=kotlin.Int? WHEN type=kotlin.Int? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: Int?' type=kotlin.Int? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'inc(): Int' type=kotlin.Int origin=null - $this: GET_VAR 'tmp0_safe_receiver: Int?' type=kotlin.Int? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: Int?' type=kotlin.Int? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'inc(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'tmp0_safe_receiver: Int?' type=kotlin.Int? origin=null FUN public operator fun kotlin.Int?.get(index: kotlin.Int): kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='get(Int) on Int?: Int' @@ -36,24 +39,27 @@ FILE /safeCallWithIncrementDecrement.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: test.C? GET_VAR 'value-parameter nc: C?' type=test.C? origin=null WHEN type=kotlin.Unit origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: C?' type=test.C? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CONST Null type=kotlin.Nothing? value='null' - else: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - BLOCK type=kotlin.Int origin=POSTFIX_INCR - VAR IR_TEMPORARY_VARIABLE val tmp1_this: test.C? - GET_VAR 'tmp0_safe_receiver: C?' type=test.C? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: C?' type=test.C? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int origin=POSTFIX_INCR - VAR IR_TEMPORARY_VARIABLE val tmp2: kotlin.Int - CALL '() on C?: Int' type=kotlin.Int origin=POSTFIX_INCR + VAR IR_TEMPORARY_VARIABLE val tmp1_this: test.C? + GET_VAR 'tmp0_safe_receiver: C?' type=test.C? origin=null + BLOCK type=kotlin.Int origin=POSTFIX_INCR + VAR IR_TEMPORARY_VARIABLE val tmp2: kotlin.Int + CALL '() on C?: Int' type=kotlin.Int origin=POSTFIX_INCR + $this: GET_VAR 'tmp1_this: C?' type=test.C? origin=null + CALL '(Int) on C?: Unit' type=kotlin.Unit origin=POSTFIX_INCR $this: GET_VAR 'tmp1_this: C?' type=test.C? origin=null - CALL '(Int) on C?: Unit' type=kotlin.Unit origin=POSTFIX_INCR - $this: GET_VAR 'tmp1_this: C?' type=test.C? origin=null - value: CALL 'inc() on Int?: Int?' type=kotlin.Int? origin=POSTFIX_INCR - $receiver: GET_VAR 'tmp2: Int' type=kotlin.Int origin=null - GET_VAR 'tmp2: Int' type=kotlin.Int origin=null + value: CALL 'inc() on Int?: Int?' type=kotlin.Int? origin=POSTFIX_INCR + $receiver: GET_VAR 'tmp2: Int' type=kotlin.Int origin=null + GET_VAR 'tmp2: Int' type=kotlin.Int origin=null FUN public fun testArrayAccess(nc: test.C?): kotlin.Unit BLOCK_BODY TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit @@ -63,12 +69,15 @@ FILE /safeCallWithIncrementDecrement.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: test.C? GET_VAR 'value-parameter nc: C?' type=test.C? origin=null WHEN type=kotlin.Int? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: C?' type=test.C? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL '() on C?: Int' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'tmp0_safe_receiver: C?' type=test.C? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: C?' type=test.C? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL '() on C?: Int' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'tmp0_safe_receiver: C?' type=test.C? origin=null VAR IR_TEMPORARY_VARIABLE val tmp4_index0: kotlin.Int CONST Int type=kotlin.Int value='0' VAR IR_TEMPORARY_VARIABLE val tmp5: kotlin.Int diff --git a/compiler/testData/ir/irText/expressions/safeCalls.txt b/compiler/testData/ir/irText/expressions/safeCalls.txt index 2b3f0a76cdd..32d78987e5b 100644 --- a/compiler/testData/ir/irText/expressions/safeCalls.txt +++ b/compiler/testData/ir/irText/expressions/safeCalls.txt @@ -31,12 +31,15 @@ FILE /safeCalls.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.String? GET_VAR 'value-parameter x: String?' type=kotlin.String? origin=null WHEN type=kotlin.Int? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null FUN public fun test2(x: kotlin.String?): kotlin.Int? BLOCK_BODY RETURN type=kotlin.Nothing from='test2(String?): Int?' @@ -44,12 +47,15 @@ FILE /safeCalls.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.String? GET_VAR 'value-parameter x: String?' type=kotlin.String? origin=null WHEN type=kotlin.Int? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'hashCode(): Int' type=kotlin.Int origin=null - $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'hashCode(): Int' type=kotlin.Int origin=null + $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null FUN public fun test3(x: kotlin.String?, y: kotlin.Any?): kotlin.Boolean? BLOCK_BODY RETURN type=kotlin.Nothing from='test3(String?, Any?): Boolean?' @@ -57,27 +63,33 @@ FILE /safeCalls.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.String? GET_VAR 'value-parameter x: String?' type=kotlin.String? origin=null WHEN type=kotlin.Boolean? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null - $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null - other: GET_VAR 'value-parameter y: Any?' type=kotlin.Any? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'equals(Any?): Boolean' type=kotlin.Boolean origin=null + $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + other: GET_VAR 'value-parameter y: Any?' type=kotlin.Any? origin=null FUN public fun test4(x: Ref?): kotlin.Unit BLOCK_BODY BLOCK type=kotlin.Unit origin=SAFE_CALL VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: Ref? GET_VAR 'value-parameter x: Ref?' type=Ref? origin=null WHEN type=kotlin.Unit origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: Ref?' type=Ref? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CONST Null type=kotlin.Nothing? value='null' - else: CALL '(Int): Unit' type=kotlin.Unit origin=EQ - $this: GET_VAR 'tmp0_safe_receiver: Ref?' type=Ref? origin=null - : CONST Int type=kotlin.Int value='0' + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: Ref?' type=Ref? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL '(Int): Unit' type=kotlin.Unit origin=EQ + $this: GET_VAR 'tmp0_safe_receiver: Ref?' type=Ref? origin=null + : CONST Int type=kotlin.Int value='0' FUN public fun IHost.test5(s: kotlin.String?): kotlin.Int? BLOCK_BODY RETURN type=kotlin.Nothing from='test5(String?) on IHost: Int?' @@ -85,10 +97,13 @@ FILE /safeCalls.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.String? GET_VAR 'value-parameter s: String?' type=kotlin.String? origin=null WHEN type=kotlin.Int? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'extLength() on String: Int' type=kotlin.Int origin=null - $this: $RECEIVER of 'test5(String?) on IHost: Int?' type=IHost - $receiver: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'extLength() on String: Int' type=kotlin.Int origin=null + $this: $RECEIVER of 'test5(String?) on IHost: Int?' type=IHost + $receiver: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.txt b/compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.txt index d413daf98d5..3047c11816b 100644 --- a/compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.txt +++ b/compiler/testData/ir/irText/expressions/setFieldWithImplicitCast.txt @@ -6,11 +6,12 @@ FILE /Derived.kt INSTANCE_INITIALIZER_CALL classDescriptor='Derived' FUN public final fun setValue(v: kotlin.Any): kotlin.Unit BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.String - GET_VAR 'value-parameter v: Any' type=kotlin.Any origin=null - then: BLOCK type=kotlin.Unit origin=null - SET_FIELD 'value: String!' type=kotlin.Unit origin=EQ - receiver: THIS of 'Derived' type=Derived - value: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String! - GET_VAR 'value-parameter v: Any' type=kotlin.Any origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.String + GET_VAR 'value-parameter v: Any' type=kotlin.Any origin=null + then: BLOCK type=kotlin.Unit origin=null + SET_FIELD 'value: String!' type=kotlin.Unit origin=EQ + receiver: THIS of 'Derived' type=Derived + value: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String! + GET_VAR 'value-parameter v: Any' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/smartCasts.txt b/compiler/testData/ir/irText/expressions/smartCasts.txt index 03d7a66d927..67bc7514f51 100644 --- a/compiler/testData/ir/irText/expressions/smartCasts.txt +++ b/compiler/testData/ir/irText/expressions/smartCasts.txt @@ -13,10 +13,11 @@ FILE /smartCasts.kt GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null FUN public fun test1(x: kotlin.Any): kotlin.Unit BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null - then: RETURN type=kotlin.Nothing from='test1(Any): Unit' + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: RETURN type=kotlin.Nothing from='test1(Any): Unit' CALL 'println(Int): Unit' type=kotlin.Unit origin=null message: CALL '(): Int' type=kotlin.Int origin=GET_PROPERTY $this: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String @@ -34,22 +35,24 @@ FILE /smartCasts.kt GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null FUN public fun test2(x: kotlin.Any): kotlin.String BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null - then: RETURN type=kotlin.Nothing from='test2(Any): String' - CONST String type=kotlin.String value='' + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: RETURN type=kotlin.Nothing from='test2(Any): String' + CONST String type=kotlin.String value='' RETURN type=kotlin.Nothing from='test2(Any): String' CALL 'overloaded(String): String' type=kotlin.String origin=null s: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null FUN public fun test3(x: kotlin.Any): kotlin.String BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null - then: RETURN type=kotlin.Nothing from='test3(Any): String' - CONST String type=kotlin.String value='' + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + then: RETURN type=kotlin.Nothing from='test3(Any): String' + CONST String type=kotlin.String value='' RETURN type=kotlin.Nothing from='test3(Any): String' TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.String GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.txt b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.txt index 26226823a7b..7719bde096c 100644 --- a/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.txt +++ b/compiler/testData/ir/irText/expressions/smartCastsWithDestructuring.txt @@ -11,10 +11,11 @@ FILE /smartCastsWithDestructuring.kt CONST String type=kotlin.String value='' FUN public fun test(x: I1): kotlin.Unit BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=I2 - GET_VAR 'value-parameter x: I1' type=I1 origin=null - then: RETURN type=kotlin.Nothing from='test(I1): Unit' + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=I2 + GET_VAR 'value-parameter x: I1' type=I1 origin=null + then: RETURN type=kotlin.Nothing from='test(I1): Unit' COMPOSITE type=kotlin.Unit origin=DESTRUCTURING_DECLARATION VAR IR_TEMPORARY_VARIABLE val tmp0_container: I1 GET_VAR 'value-parameter x: I1' type=I1 origin=null diff --git a/compiler/testData/ir/irText/expressions/throw.txt b/compiler/testData/ir/irText/expressions/throw.txt index dde5f8fc54d..491c3a95388 100644 --- a/compiler/testData/ir/irText/expressions/throw.txt +++ b/compiler/testData/ir/irText/expressions/throw.txt @@ -5,10 +5,11 @@ FILE /throw.kt CALL 'constructor Throwable()' type=kotlin.Throwable origin=null FUN public fun testImplicitCast(a: kotlin.Any): kotlin.Unit BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.Throwable - GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null - then: BLOCK type=kotlin.Nothing origin=null - THROW type=kotlin.Nothing - TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Throwable - GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.Throwable + GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null + then: BLOCK type=kotlin.Nothing origin=null + THROW type=kotlin.Nothing + TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Throwable + GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null diff --git a/compiler/testData/ir/irText/expressions/tryCatchWithImplicitCast.txt b/compiler/testData/ir/irText/expressions/tryCatchWithImplicitCast.txt index 8e0875cc43e..fd4eaffaf15 100644 --- a/compiler/testData/ir/irText/expressions/tryCatchWithImplicitCast.txt +++ b/compiler/testData/ir/irText/expressions/tryCatchWithImplicitCast.txt @@ -1,10 +1,11 @@ FILE /tryCatchWithImplicitCast.kt FUN public fun testImplicitCast(a: kotlin.Any): kotlin.Unit BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String - GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null - then: RETURN type=kotlin.Nothing from='testImplicitCast(Any): Unit' + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.String + GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null + then: RETURN type=kotlin.Nothing from='testImplicitCast(Any): Unit' VAR val t: kotlin.String TRY type=kotlin.String try: BLOCK type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/expressions/typeArguments.txt b/compiler/testData/ir/irText/expressions/typeArguments.txt index 598362dab35..7cea1e6a5cc 100644 --- a/compiler/testData/ir/irText/expressions/typeArguments.txt +++ b/compiler/testData/ir/irText/expressions/typeArguments.txt @@ -3,10 +3,13 @@ FILE /typeArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='test1(Any): Boolean' WHEN type=kotlin.Boolean origin=ANDAND - if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.Array<*> - GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null - then: CALL 'isArrayOf() on Array<*>: Boolean' type=kotlin.Boolean origin=null - : String - $receiver: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Array<*> + BRANCH + if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.Array<*> GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null - else: CONST Boolean type=kotlin.Boolean value='false' + then: CALL 'isArrayOf() on Array<*>: Boolean' type=kotlin.Boolean origin=null + : String + $receiver: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Array<*> + GET_VAR 'value-parameter x: Any' type=kotlin.Any origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CONST Boolean type=kotlin.Boolean value='false' diff --git a/compiler/testData/ir/irText/expressions/varargWithImplicitCast.txt b/compiler/testData/ir/irText/expressions/varargWithImplicitCast.txt index 4678452bccd..e56bd94edcb 100644 --- a/compiler/testData/ir/irText/expressions/varargWithImplicitCast.txt +++ b/compiler/testData/ir/irText/expressions/varargWithImplicitCast.txt @@ -1,11 +1,12 @@ FILE /varargWithImplicitCast.kt FUN public fun testScalar(a: kotlin.Any): kotlin.IntArray BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.Int - GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null - then: RETURN type=kotlin.Nothing from='testScalar(Any): IntArray' - CALL 'intArrayOf(vararg Int): IntArray' type=kotlin.IntArray origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.Int + GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null + then: RETURN type=kotlin.Nothing from='testScalar(Any): IntArray' + CALL 'intArrayOf(vararg Int): IntArray' type=kotlin.IntArray origin=null RETURN type=kotlin.Nothing from='testScalar(Any): IntArray' CALL 'intArrayOf(vararg Int): IntArray' type=kotlin.IntArray origin=null elements: VARARG type=IntArray varargElementType=Int @@ -13,11 +14,12 @@ FILE /varargWithImplicitCast.kt GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null FUN public fun testSpread(a: kotlin.Any): kotlin.IntArray BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.IntArray - GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null - then: RETURN type=kotlin.Nothing from='testSpread(Any): IntArray' - CALL 'intArrayOf(vararg Int): IntArray' type=kotlin.IntArray origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=NOT_INSTANCEOF typeOperand=kotlin.IntArray + GET_VAR 'value-parameter a: Any' type=kotlin.Any origin=null + then: RETURN type=kotlin.Nothing from='testSpread(Any): IntArray' + CALL 'intArrayOf(vararg Int): IntArray' type=kotlin.IntArray origin=null RETURN type=kotlin.Nothing from='testSpread(Any): IntArray' CALL 'intArrayOf(vararg Int): IntArray' type=kotlin.IntArray origin=null elements: VARARG type=IntArray varargElementType=Int diff --git a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.txt b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.txt index daff5c66601..0390e915a6c 100644 --- a/compiler/testData/ir/irText/expressions/variableAsFunctionCall.txt +++ b/compiler/testData/ir/irText/expressions/variableAsFunctionCall.txt @@ -34,16 +34,22 @@ FILE /variableAsFunctionCall.kt VAR IR_TEMPORARY_VARIABLE val tmp0_safe_receiver: kotlin.String? GET_VAR 'value-parameter ns: String?' type=kotlin.String? origin=null WHEN type=(() -> kotlin.String)? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'k() on String: () -> String' type=() -> kotlin.String origin=null - $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'k() on String: () -> String' type=() -> kotlin.String origin=null + $this: GET_VAR 'tmp0_safe_receiver: String?' type=kotlin.String? origin=null WHEN type=kotlin.String? origin=SAFE_CALL - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp1_safe_receiver: (() -> String)?' type=(() -> kotlin.String)? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST Null type=kotlin.Nothing? value='null' - else: CALL 'invoke(): String' type=kotlin.String origin=null - $this: GET_VAR 'tmp1_safe_receiver: (() -> String)?' type=(() -> kotlin.String)? origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp1_safe_receiver: (() -> String)?' type=(() -> kotlin.String)? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST Null type=kotlin.Nothing? value='null' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'invoke(): String' type=kotlin.String origin=null + $this: GET_VAR 'tmp1_safe_receiver: (() -> String)?' type=(() -> kotlin.String)? origin=null diff --git a/compiler/testData/ir/irText/expressions/when.txt b/compiler/testData/ir/irText/expressions/when.txt index 4ef411b64a9..576aec23443 100644 --- a/compiler/testData/ir/irText/expressions/when.txt +++ b/compiler/testData/ir/irText/expressions/when.txt @@ -11,46 +11,58 @@ FILE /when.kt VAR IR_TEMPORARY_VARIABLE val tmp0_subject: kotlin.Any? GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null WHEN type=kotlin.String origin=WHEN - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Any?' type=kotlin.Any? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST String type=kotlin.String value='null' - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Any?' type=kotlin.Any? origin=null - arg1: GET_OBJECT 'A' type=A - then: CONST String type=kotlin.String value='A' - if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.String - GET_VAR 'tmp0_subject: Any?' type=kotlin.Any? origin=null - then: CONST String type=kotlin.String value='String' - if: CALL 'contains(Any) on Iterable: Boolean' type=kotlin.Boolean origin=IN - : Any - $receiver: CALL 'setOf(): Set' type=kotlin.collections.Set origin=null - : Nothing - element: GET_VAR 'tmp0_subject: Any?' type=kotlin.Any? origin=null - then: CONST String type=kotlin.String value='nothingness?' - else: CONST String type=kotlin.String value='something' + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Any?' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST String type=kotlin.String value='null' + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Any?' type=kotlin.Any? origin=null + arg1: GET_OBJECT 'A' type=A + then: CONST String type=kotlin.String value='A' + BRANCH + if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.String + GET_VAR 'tmp0_subject: Any?' type=kotlin.Any? origin=null + then: CONST String type=kotlin.String value='String' + BRANCH + if: CALL 'contains(Any) on Iterable: Boolean' type=kotlin.Boolean origin=IN + : Any + $receiver: CALL 'setOf(): Set' type=kotlin.collections.Set origin=null + : Nothing + element: GET_VAR 'tmp0_subject: Any?' type=kotlin.Any? origin=null + then: CONST String type=kotlin.String value='nothingness?' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CONST String type=kotlin.String value='something' FUN public fun test(x: kotlin.Any?): kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='test(Any?): String' WHEN type=kotlin.String origin=WHEN - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null - arg1: CONST Null type=kotlin.Nothing? value='null' - then: CONST String type=kotlin.String value='null' - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null - arg1: GET_OBJECT 'A' type=A - then: CONST String type=kotlin.String value='A' - if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.String - GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null - then: CONST String type=kotlin.String value='String' - if: CALL 'contains(Any) on Iterable: Boolean' type=kotlin.Boolean origin=IN - : Any - $receiver: CALL 'setOf(): Set' type=kotlin.collections.Set origin=null - : Nothing - element: GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null - then: CONST String type=kotlin.String value='nothingness?' - else: CONST String type=kotlin.String value='something' + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null + arg1: CONST Null type=kotlin.Nothing? value='null' + then: CONST String type=kotlin.String value='null' + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null + arg1: GET_OBJECT 'A' type=A + then: CONST String type=kotlin.String value='A' + BRANCH + if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.String + GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null + then: CONST String type=kotlin.String value='String' + BRANCH + if: CALL 'contains(Any) on Iterable: Boolean' type=kotlin.Boolean origin=IN + : Any + $receiver: CALL 'setOf(): Set' type=kotlin.collections.Set origin=null + : Nothing + element: GET_VAR 'value-parameter x: Any?' type=kotlin.Any? origin=null + then: CONST String type=kotlin.String value='nothingness?' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CONST String type=kotlin.String value='something' FUN public fun testComma(x: kotlin.Int): kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='testComma(Int): String' @@ -58,46 +70,69 @@ FILE /when.kt VAR IR_TEMPORARY_VARIABLE val tmp0_subject: kotlin.Int GET_VAR 'value-parameter x: Int' type=kotlin.Int origin=null WHEN type=kotlin.String origin=WHEN - if: WHEN type=kotlin.Boolean origin=WHEN_COMMA + BRANCH if: WHEN type=kotlin.Boolean origin=WHEN_COMMA - if: WHEN type=kotlin.Boolean origin=WHEN_COMMA + BRANCH + if: WHEN type=kotlin.Boolean origin=WHEN_COMMA + BRANCH + if: WHEN type=kotlin.Boolean origin=WHEN_COMMA + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='1' + then: CONST Boolean type=kotlin.Boolean value='true' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='2' + then: CONST Boolean type=kotlin.Boolean value='true' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='3' + then: CONST Boolean type=kotlin.Boolean value='true' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='4' + then: CONST String type=kotlin.String value='1234' + BRANCH + if: WHEN type=kotlin.Boolean origin=WHEN_COMMA + BRANCH + if: WHEN type=kotlin.Boolean origin=WHEN_COMMA + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='5' + then: CONST Boolean type=kotlin.Boolean value='true' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='6' + then: CONST Boolean type=kotlin.Boolean value='true' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='7' + then: CONST String type=kotlin.String value='567' + BRANCH + if: WHEN type=kotlin.Boolean origin=WHEN_COMMA + BRANCH if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='1' + arg1: CONST Int type=kotlin.Int value='8' then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='2' - then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='3' - then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='4' - then: CONST String type=kotlin.String value='1234' - if: WHEN type=kotlin.Boolean origin=WHEN_COMMA - if: WHEN type=kotlin.Boolean origin=WHEN_COMMA - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='5' - then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='6' - then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='7' - then: CONST String type=kotlin.String value='567' - if: WHEN type=kotlin.Boolean origin=WHEN_COMMA - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='8' - then: CONST Boolean type=kotlin.Boolean value='true' - else: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'tmp0_subject: Int' type=kotlin.Int origin=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='9' + then: CONST String type=kotlin.String value='89' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CONST String type=kotlin.String value='?' diff --git a/compiler/testData/ir/irText/expressions/whenElse.txt b/compiler/testData/ir/irText/expressions/whenElse.txt index 1808d652643..02e8ffbf73e 100644 --- a/compiler/testData/ir/irText/expressions/whenElse.txt +++ b/compiler/testData/ir/irText/expressions/whenElse.txt @@ -3,4 +3,6 @@ FILE /whenElse.kt BLOCK_BODY RETURN type=kotlin.Nothing from='test(): Int' WHEN type=kotlin.Int origin=WHEN - else: CONST Int type=kotlin.Int value='42' + BRANCH + if: CONST Boolean type=kotlin.Boolean value='true' + then: CONST Int type=kotlin.Int value='42' diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.txt index b9ba1bdb22a..620fb9b4a5b 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.txt @@ -71,15 +71,16 @@ FILE /whileDoWhile.kt BLOCK_BODY VAR val a: kotlin.Any? = null CONST Null type=kotlin.Nothing? value='null' - WHEN type=kotlin.Unit origin=IF - if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.Boolean - GET_VAR 'a: Any?' type=kotlin.Any? origin=null - then: BLOCK type=kotlin.Unit origin=null - WHILE label=null origin=WHILE_LOOP - condition: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Boolean - GET_VAR 'a: Any?' type=kotlin.Any? origin=null - body: BLOCK type=kotlin.Unit origin=null - DO_WHILE label=null origin=DO_WHILE_LOOP - body: BLOCK type=kotlin.Unit origin=null - condition: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Boolean - GET_VAR 'a: Any?' type=kotlin.Any? origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: TYPE_OP origin=INSTANCEOF typeOperand=kotlin.Boolean + GET_VAR 'a: Any?' type=kotlin.Any? origin=null + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Boolean + GET_VAR 'a: Any?' type=kotlin.Any? origin=null + body: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: BLOCK type=kotlin.Unit origin=null + condition: TYPE_OP origin=IMPLICIT_CAST typeOperand=kotlin.Boolean + GET_VAR 'a: Any?' type=kotlin.Any? origin=null diff --git a/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt b/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt index fc8435c468b..d158993a8ce 100644 --- a/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt +++ b/compiler/testData/ir/irText/lambdas/nonLocalReturn.txt @@ -34,11 +34,12 @@ FILE /nonLocalReturn.kt action: BLOCK type=(kotlin.Int) -> kotlin.Unit origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA local final fun (it: kotlin.Int): kotlin.Unit BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'value-parameter it: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='0' - then: RETURN type=kotlin.Nothing from='(Int): Unit' + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter it: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='0' + then: RETURN type=kotlin.Nothing from='(Int): Unit' RETURN type=kotlin.Nothing from='(Int): Unit' CALL 'print(Int): Unit' type=kotlin.Unit origin=null message: GET_VAR 'value-parameter it: Int' type=kotlin.Int origin=null @@ -51,11 +52,12 @@ FILE /nonLocalReturn.kt action: BLOCK type=(kotlin.Int) -> kotlin.Unit origin=LAMBDA FUN LOCAL_FUNCTION_FOR_LAMBDA local final fun (it: kotlin.Int): kotlin.Unit BLOCK_BODY - WHEN type=kotlin.Unit origin=IF - if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'value-parameter it: Int' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value='0' - then: RETURN type=kotlin.Nothing from='(Int): Unit' + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'value-parameter it: Int' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value='0' + then: RETURN type=kotlin.Nothing from='(Int): Unit' RETURN type=kotlin.Nothing from='(Int): Unit' CALL 'print(Int): Unit' type=kotlin.Unit origin=null message: GET_VAR 'value-parameter it: Int' type=kotlin.Int origin=null diff --git a/compiler/testData/ir/irText/regressions/coercionInLoop.txt b/compiler/testData/ir/irText/regressions/coercionInLoop.txt index 6b8c21a332c..73fddff0538 100644 --- a/compiler/testData/ir/irText/regressions/coercionInLoop.txt +++ b/compiler/testData/ir/irText/regressions/coercionInLoop.txt @@ -14,18 +14,19 @@ FILE /coercionInLoop.kt $this: GET_VAR 'x: DoubleIterator' type=kotlin.collections.DoubleIterator origin=null body: TYPE_OP origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit BLOCK type=kotlin.Int origin=null - WHEN type=kotlin.Unit origin=IF - if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ - arg0: CALL 'get(Int): Double' type=kotlin.Double origin=GET_ARRAY_ELEMENT - $this: GET_VAR 'a: DoubleArray' type=kotlin.DoubleArray origin=null - index: GET_VAR 'i: Int' type=kotlin.Int origin=null - arg1: CALL 'next(): Double' type=kotlin.Double origin=null - $this: GET_VAR 'x: DoubleIterator' type=kotlin.collections.DoubleIterator origin=null - then: RETURN type=kotlin.Nothing from='box(): String' - STRING_CONCATENATION type=kotlin.String - CONST String type=kotlin.String value='Fail ' - GET_VAR 'i: Int' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=null + BRANCH + if: CALL 'NOT(Boolean): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'EQEQ(Any?, Any?): Boolean' type=kotlin.Boolean origin=EXCLEQ + arg0: CALL 'get(Int): Double' type=kotlin.Double origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'a: DoubleArray' type=kotlin.DoubleArray origin=null + index: GET_VAR 'i: Int' type=kotlin.Int origin=null + arg1: CALL 'next(): Double' type=kotlin.Double origin=null + $this: GET_VAR 'x: DoubleIterator' type=kotlin.collections.DoubleIterator origin=null + then: RETURN type=kotlin.Nothing from='box(): String' + STRING_CONCATENATION type=kotlin.String + CONST String type=kotlin.String value='Fail ' + GET_VAR 'i: Int' type=kotlin.Int origin=null BLOCK type=kotlin.Int origin=POSTFIX_INCR VAR IR_TEMPORARY_VARIABLE val tmp0: kotlin.Int GET_VAR 'i: Int' type=kotlin.Int origin=POSTFIX_INCR