diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index f9579c02cd2..c26a9158cfc 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -18,10 +18,7 @@ import org.jetbrains.kotlin.fir.declarations.* import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.deserialization.toQualifiedPropertyAccessExpression import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.expressions.impl.FirContractCallBlock -import org.jetbrains.kotlin.fir.expressions.impl.FirElseIfTrueCondition -import org.jetbrains.kotlin.fir.expressions.impl.FirEmptyExpressionBlock -import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression +import org.jetbrains.kotlin.fir.expressions.impl.* import org.jetbrains.kotlin.fir.extensions.extensionService import org.jetbrains.kotlin.fir.references.* import org.jetbrains.kotlin.fir.resolve.defaultType @@ -862,7 +859,7 @@ class Fir2IrVisitor( override fun visitVariableAssignment( variableAssignment: FirVariableAssignment, data: Any? - ): IrElement = whileAnalysing(session, variableAssignment) { + ): IrExpression = whileAnalysing(session, variableAssignment) { val explicitReceiverExpression = variableAssignment.explicitReceiver?.let { receiverExpression -> convertToIrReceiverExpression( receiverExpression, variableAssignment.unwrapLValue()!! @@ -1098,6 +1095,12 @@ class Fir2IrVisitor( return it } } + if (this is FirSingleExpressionBlock) { + when (val stmt = statement) { + is FirExpression -> return convertToIrExpression(stmt) + !is FirDeclaration -> return stmt.accept(this@Fir2IrVisitor, null) as IrExpression + } + } if (source?.kind is KtRealSourceElementKind) { val lastStatementHasNothingType = (statements.lastOrNull() as? FirExpression)?.resolvedType?.isNothing == true return statements.convertToIrBlock(source, origin, forceUnitType = origin?.isLoop == true || lastStatementHasNothingType) diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java index 954475624b1..9c42d967811 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirLightTreeJvmIrTextTestGenerated.java @@ -1622,6 +1622,24 @@ public class FirLightTreeJvmIrTextTestGenerated extends AbstractFirLightTreeJvmI runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java index 2c00cf655fc..3982baab89e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/FirPsiJvmIrTextTestGenerated.java @@ -1622,6 +1622,24 @@ public class FirPsiJvmIrTextTestGenerated extends AbstractFirPsiJvmIrTextTest { runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.ir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.ir.txt index f11b75a751d..eb728be8e30 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.ir.txt @@ -15,11 +15,10 @@ FILE fqName: fileName:/withVarargViewedAsArray.kt VAR FOR_LOOP_VARIABLE name:arg type:kotlin.Int [val] CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT $this: GET_VAR 'val tmp_0: kotlin.collections.IntIterator declared in .sum' type=kotlin.collections.IntIterator origin=null - BLOCK type=kotlin.Unit origin=null - SET_VAR 'var result: kotlin.Int declared in .sum' type=kotlin.Unit origin=PLUSEQ - CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'var result: kotlin.Int declared in .sum' type=kotlin.Int origin=null - other: GET_VAR 'val arg: kotlin.Int declared in .sum' type=kotlin.Int origin=null + SET_VAR 'var result: kotlin.Int declared in .sum' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var result: kotlin.Int declared in .sum' type=kotlin.Int origin=null + other: GET_VAR 'val arg: kotlin.Int declared in .sum' type=kotlin.Int origin=null RETURN type=kotlin.Nothing from='public final fun sum (vararg args: kotlin.Int): kotlin.Int declared in ' GET_VAR 'var result: kotlin.Int declared in .sum' type=kotlin.Int origin=null FUN name:nsum visibility:public modality:FINAL <> (args:kotlin.Array) returnType:kotlin.Int diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt index 83f6269b5b6..8bbcd8deaac 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.kt.txt @@ -4,9 +4,7 @@ fun sum(vararg args: Int): Int { val tmp_0: IntIterator = args.iterator() while (tmp_0.hasNext()) { // BLOCK val arg: Int = tmp_0.next() - { // BLOCK - result = result.plus(other = arg) - } + result = result.plus(other = arg) } } return result diff --git a/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.ir.txt b/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.ir.txt index 2c1e0dbb024..29c1da32de1 100644 --- a/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.ir.txt @@ -66,9 +66,8 @@ FILE fqName: fileName:/exhaustiveWhenElseBranch.kt if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_0: .A declared in .testVariableAssignment_throws' type=.A origin=null arg1: GET_ENUM 'ENUM_ENTRY name:V1' type=.A - then: BLOCK type=kotlin.Unit origin=null - SET_VAR 'val x: kotlin.Int declared in .testVariableAssignment_throws' type=kotlin.Unit origin=EQ - CONST Int type=kotlin.Int value=11 + then: SET_VAR 'val x: kotlin.Int declared in .testVariableAssignment_throws' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=11 BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CALL 'public final fun noWhenBranchMatchedException (): kotlin.Nothing declared in kotlin.internal.ir' type=kotlin.Nothing origin=null diff --git a/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.kt.txt b/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.kt.txt index 12345b2c463..2c8a0efe76e 100644 --- a/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/exhaustiveWhenElseBranch.fir.kt.txt @@ -21,9 +21,7 @@ fun testVariableAssignment_throws(a: A) { { // BLOCK val tmp_0: A = a when { - EQEQ(arg0 = tmp_0, arg1 = A.V1) -> { // BLOCK - x = 11 - } + EQEQ(arg0 = tmp_0, arg1 = A.V1) -> x = 11 else -> noWhenBranchMatchedException() } } diff --git a/compiler/testData/ir/irText/expressions/ifWithArrayOperation.fir.ir.txt b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.fir.ir.txt new file mode 100644 index 00000000000..def960f32bb --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.fir.ir.txt @@ -0,0 +1,227 @@ +FILE fqName: fileName:/ifWithArrayOperation.kt + FUN name:topLevelMethod visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:array type:kotlin.IntArray [val] + CALL 'public final fun intArrayOf (vararg elements: kotlin.Int): kotlin.IntArray declared in kotlin' type=kotlin.IntArray origin=null + elements: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=1 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=2 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=3 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=4 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=5 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_0: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_1: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_0: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_1: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=6 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_2: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_3: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_2: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_3: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=7 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_4: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_5: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_4: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_5: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=8 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_6: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_7: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_6: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_7: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=9 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_8: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=10 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=11 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_9 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_9: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=12 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=13 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_10: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_12 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_11: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_12: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_11: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_12: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=14 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_13 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_14 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_13: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_14: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_13: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_14: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=15 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_15 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=null + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_15: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_16 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_17 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_16: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_17: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_16: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_17: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=16 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_18 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_19 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_18: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_19: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_18: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_19: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=17 diff --git a/compiler/testData/ir/irText/expressions/ifWithArrayOperation.fir.kt.txt b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.fir.kt.txt new file mode 100644 index 00000000000..9dac64d8cf2 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.fir.kt.txt @@ -0,0 +1,111 @@ +fun topLevelMethod() { + val array: IntArray = intArrayOf(elements = [1]) + when { + true -> { // BLOCK + array.set(index = 0, value = 2) + } + else -> { // BLOCK + array.set(index = 0, value = 3) + } + } + when { + true -> { // BLOCK + array.set(index = 0, value = 4) + } + else -> { // BLOCK + array.set(index = 0, value = 5) + } + } + when { + true -> { // BLOCK + { // BLOCK + val tmp_0: IntArray = array + val tmp_1: Int = 0 + tmp_0.set(index = tmp_1, value = tmp_0.get(index = tmp_1).plus(other = 6)) + } + } + else -> { // BLOCK + { // BLOCK + val tmp_2: IntArray = array + val tmp_3: Int = 0 + tmp_2.set(index = tmp_3, value = tmp_2.get(index = tmp_3).plus(other = 7)) + } + } + } + when { + true -> { // BLOCK + { // BLOCK + val tmp_4: IntArray = array + val tmp_5: Int = 0 + tmp_4.set(index = tmp_5, value = tmp_4.get(index = tmp_5).plus(other = 8)) + } + } + else -> { // BLOCK + { // BLOCK + val tmp_6: IntArray = array + val tmp_7: Int = 0 + tmp_6.set(index = tmp_7, value = tmp_6.get(index = tmp_7).plus(other = 9)) + } + } + } + { // BLOCK + val tmp_8: Int = array.get(index = 0) + when { + EQEQ(arg0 = tmp_8, arg1 = 1) -> { // BLOCK + array.set(index = 0, value = 10) + } + else -> { // BLOCK + array.set(index = 0, value = 11) + } + } + } + { // BLOCK + val tmp_9: Int = array.get(index = 0) + when { + EQEQ(arg0 = tmp_9, arg1 = 1) -> { // BLOCK + array.set(index = 0, value = 12) + } + else -> { // BLOCK + array.set(index = 0, value = 13) + } + } + } + { // BLOCK + val tmp_10: Int = array.get(index = 0) + when { + EQEQ(arg0 = tmp_10, arg1 = 1) -> { // BLOCK + { // BLOCK + val tmp_11: IntArray = array + val tmp_12: Int = 0 + tmp_11.set(index = tmp_12, value = tmp_11.get(index = tmp_12).plus(other = 14)) + } + } + else -> { // BLOCK + { // BLOCK + val tmp_13: IntArray = array + val tmp_14: Int = 0 + tmp_13.set(index = tmp_14, value = tmp_13.get(index = tmp_14).plus(other = 15)) + } + } + } + } + { // BLOCK + val tmp_15: Int = array.get(index = 0) + when { + EQEQ(arg0 = tmp_15, arg1 = 1) -> { // BLOCK + { // BLOCK + val tmp_16: IntArray = array + val tmp_17: Int = 0 + tmp_16.set(index = tmp_17, value = tmp_16.get(index = tmp_17).plus(other = 16)) + } + } + else -> { // BLOCK + { // BLOCK + val tmp_18: IntArray = array + val tmp_19: Int = 0 + tmp_18.set(index = tmp_19, value = tmp_18.get(index = tmp_19).plus(other = 17)) + } + } + } + } +} diff --git a/compiler/testData/ir/irText/expressions/ifWithArrayOperation.ir.txt b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.ir.txt new file mode 100644 index 00000000000..0f2a9020547 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.ir.txt @@ -0,0 +1,219 @@ +FILE fqName: fileName:/ifWithArrayOperation.kt + FUN name:topLevelMethod visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:array type:kotlin.IntArray [val] + CALL 'public final fun intArrayOf (vararg elements: kotlin.Int): kotlin.IntArray declared in kotlin' type=kotlin.IntArray origin=null + elements: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + CONST Int type=kotlin.Int value=1 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=2 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=3 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=4 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=5 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_0: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_1: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_0: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_1: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=6 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_2: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_3: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_2: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_3: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=7 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_4: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_5: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_4: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_5: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=8 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_6: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_7: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_6: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_7: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=9 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_8: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=10 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=11 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_9 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_9: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=12 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=EQ + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + value: CONST Int type=kotlin.Int value=13 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_10: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_12 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_11: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_12: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_11: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_12: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=14 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_13 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_14 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_13: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_14: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_13: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_14: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=15 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_15 type:kotlin.Int [val] + CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=GET_ARRAY_ELEMENT + $this: GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: CONST Int type=kotlin.Int value=0 + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_15: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_16 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_17 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_16: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_17: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_16: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_17: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=16 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=PLUSEQ + VAR IR_TEMPORARY_VARIABLE name:tmp_18 type:kotlin.IntArray [val] + GET_VAR 'val array: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_19 type:kotlin.Int [val] + CONST Int type=kotlin.Int value=0 + CALL 'public final fun set (index: kotlin.Int, value: kotlin.Int): kotlin.Unit declared in kotlin.IntArray' type=kotlin.Unit origin=PLUSEQ + $this: GET_VAR 'val tmp_18: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_19: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + value: CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: CALL 'public final fun get (index: kotlin.Int): kotlin.Int declared in kotlin.IntArray' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'val tmp_18: kotlin.IntArray declared in .topLevelMethod' type=kotlin.IntArray origin=null + index: GET_VAR 'val tmp_19: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=17 diff --git a/compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt new file mode 100644 index 00000000000..a2dcb58d8a1 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt @@ -0,0 +1,29 @@ +fun topLevelMethod() { + val array = intArrayOf(1) + + if(true) { array[0] = 2 } else { array[0] = 3 } + if(true) array[0] = 4 else array[0] = 5 + + if(true) { array[0] += 6 } else { array[0] += 7 } + if(true) array[0] += 8 else array[0] += 9 + + when(array[0]) { + 1 -> { array[0] = 10 } + else -> { array[0] = 11 } + } + + when(array[0]) { + 1 -> array[0] = 12 + else -> array[0] = 13 + } + + when(array[0]) { + 1 -> { array[0] += 14 } + else -> { array[0] += 15 } + } + + when(array[0]) { + 1 -> array[0] += 16 + else -> array[0] += 17 + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt.txt b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt.txt new file mode 100644 index 00000000000..edecc99a6ec --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt.txt @@ -0,0 +1,95 @@ +fun topLevelMethod() { + val array: IntArray = intArrayOf(elements = [1]) + when { + true -> { // BLOCK + array.set(index = 0, value = 2) + } + else -> { // BLOCK + array.set(index = 0, value = 3) + } + } + when { + true -> array.set(index = 0, value = 4) + else -> array.set(index = 0, value = 5) + } + when { + true -> { // BLOCK + { // BLOCK + val tmp_0: IntArray = array + val tmp_1: Int = 0 + tmp_0.set(index = tmp_1, value = tmp_0.get(index = tmp_1).plus(other = 6)) + } + } + else -> { // BLOCK + { // BLOCK + val tmp_2: IntArray = array + val tmp_3: Int = 0 + tmp_2.set(index = tmp_3, value = tmp_2.get(index = tmp_3).plus(other = 7)) + } + } + } + when { + true -> { // BLOCK + val tmp_4: IntArray = array + val tmp_5: Int = 0 + tmp_4.set(index = tmp_5, value = tmp_4.get(index = tmp_5).plus(other = 8)) + } + else -> { // BLOCK + val tmp_6: IntArray = array + val tmp_7: Int = 0 + tmp_6.set(index = tmp_7, value = tmp_6.get(index = tmp_7).plus(other = 9)) + } + } + { // BLOCK + val tmp_8: Int = array.get(index = 0) + when { + EQEQ(arg0 = tmp_8, arg1 = 1) -> { // BLOCK + array.set(index = 0, value = 10) + } + else -> { // BLOCK + array.set(index = 0, value = 11) + } + } + } + { // BLOCK + val tmp_9: Int = array.get(index = 0) + when { + EQEQ(arg0 = tmp_9, arg1 = 1) -> array.set(index = 0, value = 12) + else -> array.set(index = 0, value = 13) + } + } + { // BLOCK + val tmp_10: Int = array.get(index = 0) + when { + EQEQ(arg0 = tmp_10, arg1 = 1) -> { // BLOCK + { // BLOCK + val tmp_11: IntArray = array + val tmp_12: Int = 0 + tmp_11.set(index = tmp_12, value = tmp_11.get(index = tmp_12).plus(other = 14)) + } + } + else -> { // BLOCK + { // BLOCK + val tmp_13: IntArray = array + val tmp_14: Int = 0 + tmp_13.set(index = tmp_14, value = tmp_13.get(index = tmp_14).plus(other = 15)) + } + } + } + } + { // BLOCK + val tmp_15: Int = array.get(index = 0) + when { + EQEQ(arg0 = tmp_15, arg1 = 1) -> { // BLOCK + val tmp_16: IntArray = array + val tmp_17: Int = 0 + tmp_16.set(index = tmp_17, value = tmp_16.get(index = tmp_17).plus(other = 16)) + } + else -> { // BLOCK + val tmp_18: IntArray = array + val tmp_19: Int = 0 + tmp_18.set(index = tmp_19, value = tmp_18.get(index = tmp_19).plus(other = 17)) + } + } + } +} diff --git a/compiler/testData/ir/irText/expressions/ifWithArrayOperation.sig.kt.txt b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.sig.kt.txt new file mode 100644 index 00000000000..c61bfa16655 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithArrayOperation.sig.kt.txt @@ -0,0 +1,5 @@ +// CHECK: +// Mangled name: #topLevelMethod(){} +// Public signature: /topLevelMethod|3993481242130118189[0] +// Public signature debug description: topLevelMethod(){} +fun topLevelMethod(): Unit diff --git a/compiler/testData/ir/irText/expressions/ifWithAssignment.fir.ir.txt b/compiler/testData/ir/irText/expressions/ifWithAssignment.fir.ir.txt new file mode 100644 index 00000000000..9eb5fd1fc9d --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithAssignment.fir.ir.txt @@ -0,0 +1,121 @@ +FILE fqName: fileName:/ifWithAssignment.kt + FUN name:topLevelMethod visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:z type:kotlin.Int [var] + CONST Int type=kotlin.Int value=1 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=2 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=3 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=4 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=5 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=6 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=7 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=8 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=9 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=10 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=11 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=12 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=13 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_2: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=14 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=15 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_3: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=16 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=17 diff --git a/compiler/testData/ir/irText/expressions/ifWithAssignment.fir.kt.txt b/compiler/testData/ir/irText/expressions/ifWithAssignment.fir.kt.txt new file mode 100644 index 00000000000..7f39276f2c1 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithAssignment.fir.kt.txt @@ -0,0 +1,63 @@ +fun topLevelMethod() { + var z: Int = 1 + when { + true -> { // BLOCK + z = 2 + } + else -> { // BLOCK + z = 3 + } + } + when { + true -> z = 4 + else -> z = 5 + } + when { + true -> { // BLOCK + z = z.plus(other = 6) + } + else -> { // BLOCK + z = z.plus(other = 7) + } + } + when { + true -> z = z.plus(other = 8) + else -> z = z.plus(other = 9) + } + { // BLOCK + val tmp_0: Int = z + when { + EQEQ(arg0 = tmp_0, arg1 = 1) -> { // BLOCK + z = 10 + } + else -> { // BLOCK + z = 11 + } + } + } + { // BLOCK + val tmp_1: Int = z + when { + EQEQ(arg0 = tmp_1, arg1 = 1) -> z = 12 + else -> z = 13 + } + } + { // BLOCK + val tmp_2: Int = z + when { + EQEQ(arg0 = tmp_2, arg1 = 1) -> { // BLOCK + z = z.plus(other = 14) + } + else -> { // BLOCK + z = z.plus(other = 15) + } + } + } + { // BLOCK + val tmp_3: Int = z + when { + EQEQ(arg0 = tmp_3, arg1 = 1) -> z = z.plus(other = 16) + else -> z = z.plus(other = 17) + } + } +} diff --git a/compiler/testData/ir/irText/expressions/ifWithAssignment.ir.txt b/compiler/testData/ir/irText/expressions/ifWithAssignment.ir.txt new file mode 100644 index 00000000000..9dfee6ee6c0 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithAssignment.ir.txt @@ -0,0 +1,121 @@ +FILE fqName: fileName:/ifWithAssignment.kt + FUN name:topLevelMethod visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:z type:kotlin.Int [var] + CONST Int type=kotlin.Int value=1 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=2 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=3 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=4 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=5 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=6 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=7 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=8 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=9 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_0: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=10 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=11 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_1: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=12 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=EQ + CONST Int type=kotlin.Int value=13 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_2: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=14 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=15 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_3: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=16 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=17 diff --git a/compiler/testData/ir/irText/expressions/ifWithAssignment.kt b/compiler/testData/ir/irText/expressions/ifWithAssignment.kt new file mode 100644 index 00000000000..c0fc1b1d7ce --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithAssignment.kt @@ -0,0 +1,28 @@ +fun topLevelMethod() { + var z = 1 + if(true) { z = 2 } else { z = 3 } + if(true) z = 4 else z = 5 + + if(true) { z += 6 } else { z += 7 } + if(true) z += 8 else z += 9 + + when(z) { + 1 -> { z = 10 } + else -> { z = 11 } + } + + when(z) { + 1 -> z = 12 + else -> z = 13 + } + + when(z) { + 1 -> { z += 14 } + else -> { z += 15 } + } + + when(z) { + 1 -> z += 16 + else -> z += 17 + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/ifWithAssignment.kt.txt b/compiler/testData/ir/irText/expressions/ifWithAssignment.kt.txt new file mode 100644 index 00000000000..b0edc6b9b9f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithAssignment.kt.txt @@ -0,0 +1,64 @@ +fun topLevelMethod() { + var z: Int = 1 + when { + true -> { // BLOCK + z = 2 + } + else -> { // BLOCK + z = 3 + } + } + when { + true -> z = 4 + else -> z = 5 + } + when { + true -> { // BLOCK + z = z.plus(other = 6) + } + else -> { // BLOCK + z = z.plus(other = 7) + } + } + when { + true -> z = z.plus(other = 8) + else -> z = z.plus(other = 9) + } + { // BLOCK + val tmp_0: Int = z + when { + EQEQ(arg0 = tmp_0, arg1 = 1) -> { // BLOCK + z = 10 + } + else -> { // BLOCK + z = 11 + } + } + } + { // BLOCK + val tmp_1: Int = z + when { + EQEQ(arg0 = tmp_1, arg1 = 1) -> z = 12 + else -> z = 13 + } + } + { // BLOCK + val tmp_2: Int = z + when { + EQEQ(arg0 = tmp_2, arg1 = 1) -> { // BLOCK + z = z.plus(other = 14) + } + else -> { // BLOCK + z = z.plus(other = 15) + } + } + } + { // BLOCK + val tmp_3: Int = z + when { + EQEQ(arg0 = tmp_3, arg1 = 1) -> z = z.plus(other = 16) + else -> z = z.plus(other = 17) + } + } +} + diff --git a/compiler/testData/ir/irText/expressions/ifWithAssignment.sig.kt.txt b/compiler/testData/ir/irText/expressions/ifWithAssignment.sig.kt.txt new file mode 100644 index 00000000000..c61bfa16655 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithAssignment.sig.kt.txt @@ -0,0 +1,5 @@ +// CHECK: +// Mangled name: #topLevelMethod(){} +// Public signature: /topLevelMethod|3993481242130118189[0] +// Public signature debug description: topLevelMethod(){} +fun topLevelMethod(): Unit diff --git a/compiler/testData/ir/irText/expressions/ifWithLoop.fir.ir.txt b/compiler/testData/ir/irText/expressions/ifWithLoop.fir.ir.txt new file mode 100644 index 00000000000..83b58deabad --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithLoop.fir.ir.txt @@ -0,0 +1,355 @@ +FILE fqName: fileName:/ifWithLoop.kt + FUN name:topLevelMethod visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:z type:kotlin.Int [var] + CONST Int type=kotlin.Int value=1 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=2 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_1 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=3 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_1: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_1: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_2 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=4 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_2: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_2: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=5 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_3: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_3: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=6 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=7 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=8 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=9 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=10 + condition: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=11 + condition: CONST Boolean type=kotlin.Boolean value=false + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=12 + condition: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=13 + condition: CONST Boolean type=kotlin.Boolean value=false + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_4: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_5 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=14 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_5: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_5: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_6 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=15 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_6: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_6: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_7: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_8 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=16 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_8: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_8: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_9 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=17 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_9: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_9: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_10: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=18 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=19 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_11: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=20 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=21 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_12 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_12: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=22 + condition: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=23 + condition: CONST Boolean type=kotlin.Boolean value=false + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_13 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_13: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=24 + condition: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + other: CONST Int type=kotlin.Int value=25 + condition: CONST Boolean type=kotlin.Boolean value=false diff --git a/compiler/testData/ir/irText/expressions/ifWithLoop.fir.kt.txt b/compiler/testData/ir/irText/expressions/ifWithLoop.fir.kt.txt new file mode 100644 index 00000000000..990b27b9c26 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithLoop.fir.kt.txt @@ -0,0 +1,173 @@ +fun topLevelMethod() { + var z: Int = 1 + when { + true -> { // BLOCK + { // BLOCK + val tmp_0: IntIterator = 0.rangeTo(other = 2).iterator() + while (tmp_0.hasNext()) { // BLOCK + val i: Int = tmp_0.next() + z = z.plus(other = i) + } + } + } + else -> { // BLOCK + { // BLOCK + val tmp_1: IntIterator = 0.rangeTo(other = 3).iterator() + while (tmp_1.hasNext()) { // BLOCK + val i: Int = tmp_1.next() + z = z.plus(other = i) + } + } + } + } + when { + true -> { // BLOCK + val tmp_2: IntIterator = 0.rangeTo(other = 4).iterator() + while (tmp_2.hasNext()) { // BLOCK + val i: Int = tmp_2.next() + z = z.plus(other = i) + } + } + else -> { // BLOCK + val tmp_3: IntIterator = 0.rangeTo(other = 5).iterator() + while (tmp_3.hasNext()) { // BLOCK + val i: Int = tmp_3.next() + z = z.plus(other = i) + } + } + } + when { + true -> { // BLOCK + while (false) z = z.plus(other = 6) + } + else -> { // BLOCK + while (false) z = z.plus(other = 7) + } + } + when { + true -> while (false) z = z.plus(other = 8) + else -> while (false) z = z.plus(other = 9) + } + when { + true -> { // BLOCK + { // BLOCK + do// COMPOSITE { + z = z.plus(other = 10) + // } while (false) + } + } + else -> { // BLOCK + { // BLOCK + do// COMPOSITE { + z = z.plus(other = 11) + // } while (false) + } + } + } + when { + true -> { // BLOCK + do// COMPOSITE { + z = z.plus(other = 12) + // } while (false) + } + else -> { // BLOCK + do// COMPOSITE { + z = z.plus(other = 13) + // } while (false) + } + } + { // BLOCK + val tmp_4: Int = z + when { + EQEQ(arg0 = tmp_4, arg1 = 1) -> { // BLOCK + { // BLOCK + val tmp_5: IntIterator = 0.rangeTo(other = 14).iterator() + while (tmp_5.hasNext()) { // BLOCK + val i: Int = tmp_5.next() + z = z.plus(other = i) + } + } + } + else -> { // BLOCK + { // BLOCK + val tmp_6: IntIterator = 0.rangeTo(other = 15).iterator() + while (tmp_6.hasNext()) { // BLOCK + val i: Int = tmp_6.next() + z = z.plus(other = i) + } + } + } + } + } + { // BLOCK + val tmp_7: Int = z + when { + EQEQ(arg0 = tmp_7, arg1 = 1) -> { // BLOCK + val tmp_8: IntIterator = 0.rangeTo(other = 16).iterator() + while (tmp_8.hasNext()) { // BLOCK + val i: Int = tmp_8.next() + z = z.plus(other = i) + } + } + else -> { // BLOCK + val tmp_9: IntIterator = 0.rangeTo(other = 17).iterator() + while (tmp_9.hasNext()) { // BLOCK + val i: Int = tmp_9.next() + z = z.plus(other = i) + } + } + } + } + { // BLOCK + val tmp_10: Int = z + when { + EQEQ(arg0 = tmp_10, arg1 = 1) -> { // BLOCK + while (false) z = z.plus(other = 18) + } + else -> { // BLOCK + while (false) z = z.plus(other = 19) + } + } + } + { // BLOCK + val tmp_11: Int = z + when { + EQEQ(arg0 = tmp_11, arg1 = 1) -> while (false) z = z.plus(other = 20) + else -> while (false) z = z.plus(other = 21) + } + } + { // BLOCK + val tmp_12: Int = z + when { + EQEQ(arg0 = tmp_12, arg1 = 1) -> { // BLOCK + { // BLOCK + do// COMPOSITE { + z = z.plus(other = 22) + // } while (false) + } + } + else -> { // BLOCK + { // BLOCK + do// COMPOSITE { + z = z.plus(other = 23) + // } while (false) + } + } + } + } + { // BLOCK + val tmp_13: Int = z + when { + EQEQ(arg0 = tmp_13, arg1 = 1) -> { // BLOCK + do// COMPOSITE { + z = z.plus(other = 24) + // } while (false) + } + else -> { // BLOCK + do// COMPOSITE { + z = z.plus(other = 25) + // } while (false) + } + } + } +} diff --git a/compiler/testData/ir/irText/expressions/ifWithLoop.ir.txt b/compiler/testData/ir/irText/expressions/ifWithLoop.ir.txt new file mode 100644 index 00000000000..d8b1b55e448 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithLoop.ir.txt @@ -0,0 +1,355 @@ +FILE fqName: fileName:/ifWithLoop.kt + FUN name:topLevelMethod visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + VAR name:z type:kotlin.Int [var] + CONST Int type=kotlin.Int value=1 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=2 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_1 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=3 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_1: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_1: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_2 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=4 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_2: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_2: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=5 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_3: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_3: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=6 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=7 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=8 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=9 + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=10 + condition: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=11 + condition: CONST Boolean type=kotlin.Boolean value=false + WHEN type=kotlin.Unit origin=IF + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=12 + condition: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=13 + condition: CONST Boolean type=kotlin.Boolean value=false + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_4: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_5 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=14 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_5: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_5: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_6 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=15 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_6: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_6: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_7: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_8 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=16 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_8: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_8: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=FOR_LOOP + VAR FOR_LOOP_ITERATOR name:tmp_9 type:kotlin.collections.IntIterator [val] + CALL 'public open fun iterator (): kotlin.collections.IntIterator declared in kotlin.ranges.IntRange' type=kotlin.collections.IntIterator origin=FOR_LOOP_ITERATOR + $this: CALL 'public final fun rangeTo (other: kotlin.Int): kotlin.ranges.IntRange declared in kotlin.Int' type=kotlin.ranges.IntRange origin=RANGE + $this: CONST Int type=kotlin.Int value=0 + other: CONST Int type=kotlin.Int value=17 + WHILE label=null origin=FOR_LOOP_INNER_WHILE + condition: CALL 'public abstract fun hasNext (): kotlin.Boolean declared in kotlin.collections.IntIterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT + $this: GET_VAR 'val tmp_9: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE + VAR FOR_LOOP_VARIABLE name:i type:kotlin.Int [val] + CALL 'public final fun next (): kotlin.Int declared in kotlin.collections.IntIterator' type=kotlin.Int origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_9: kotlin.collections.IntIterator declared in .topLevelMethod' type=kotlin.collections.IntIterator origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: GET_VAR 'val i: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_10: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=18 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=19 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_11: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=20 + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: WHILE label=null origin=WHILE_LOOP + condition: CONST Boolean type=kotlin.Boolean value=false + body: SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=21 + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_12 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_12: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=22 + condition: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=23 + condition: CONST Boolean type=kotlin.Boolean value=false + BLOCK type=kotlin.Unit origin=WHEN + VAR IR_TEMPORARY_VARIABLE name:tmp_13 type:kotlin.Int [val] + GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: GET_VAR 'val tmp_13: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=1 + then: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=24 + condition: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=null + SET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Unit origin=PLUSEQ + CALL 'public final fun plus (other: kotlin.Int): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=PLUSEQ + $this: GET_VAR 'var z: kotlin.Int declared in .topLevelMethod' type=kotlin.Int origin=PLUSEQ + other: CONST Int type=kotlin.Int value=25 + condition: CONST Boolean type=kotlin.Boolean value=false diff --git a/compiler/testData/ir/irText/expressions/ifWithLoop.kt b/compiler/testData/ir/irText/expressions/ifWithLoop.kt new file mode 100644 index 00000000000..2b99065ddf2 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithLoop.kt @@ -0,0 +1,42 @@ +fun topLevelMethod() { + var z = 1 + + if(true) { for (i in 0..2) z += i } else { for (i in 0..3) z += i } + if(true) for (i in 0..4) z += i else for (i in 0..5) z += i + + if(true) { while(false) z += 6 } else { while(false) z += 7 } + if(true) while(false) z += 8 else while(false) z += 9 + + if(true) { do { z += 10 } while(false) } else { do { z += 11 } while(false) } + if(true) do { z += 12 } while(false) else do { z += 13 } while(false) + + when(z) { + 1 -> { for (i in 0..14) z += i } + else -> { for (i in 0..15) z += i } + } + + when(z) { + 1 -> for (i in 0..16) z += i + else -> for (i in 0..17) z += i + } + + when(z) { + 1 -> { while(false) z += 18 } + else -> { while(false) z += 19 } + } + + when(z) { + 1 -> while(false) z += 20 + else -> while(false) z += 21 + } + + when(z) { + 1 -> { do { z += 22 } while(false) } + else -> { do { z += 23 } while(false) } + } + + when(z) { + 1 -> do { z += 24 } while(false) + else -> do { z += 25 } while(false) + } +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/ifWithLoop.kt.txt b/compiler/testData/ir/irText/expressions/ifWithLoop.kt.txt new file mode 100644 index 00000000000..990b27b9c26 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithLoop.kt.txt @@ -0,0 +1,173 @@ +fun topLevelMethod() { + var z: Int = 1 + when { + true -> { // BLOCK + { // BLOCK + val tmp_0: IntIterator = 0.rangeTo(other = 2).iterator() + while (tmp_0.hasNext()) { // BLOCK + val i: Int = tmp_0.next() + z = z.plus(other = i) + } + } + } + else -> { // BLOCK + { // BLOCK + val tmp_1: IntIterator = 0.rangeTo(other = 3).iterator() + while (tmp_1.hasNext()) { // BLOCK + val i: Int = tmp_1.next() + z = z.plus(other = i) + } + } + } + } + when { + true -> { // BLOCK + val tmp_2: IntIterator = 0.rangeTo(other = 4).iterator() + while (tmp_2.hasNext()) { // BLOCK + val i: Int = tmp_2.next() + z = z.plus(other = i) + } + } + else -> { // BLOCK + val tmp_3: IntIterator = 0.rangeTo(other = 5).iterator() + while (tmp_3.hasNext()) { // BLOCK + val i: Int = tmp_3.next() + z = z.plus(other = i) + } + } + } + when { + true -> { // BLOCK + while (false) z = z.plus(other = 6) + } + else -> { // BLOCK + while (false) z = z.plus(other = 7) + } + } + when { + true -> while (false) z = z.plus(other = 8) + else -> while (false) z = z.plus(other = 9) + } + when { + true -> { // BLOCK + { // BLOCK + do// COMPOSITE { + z = z.plus(other = 10) + // } while (false) + } + } + else -> { // BLOCK + { // BLOCK + do// COMPOSITE { + z = z.plus(other = 11) + // } while (false) + } + } + } + when { + true -> { // BLOCK + do// COMPOSITE { + z = z.plus(other = 12) + // } while (false) + } + else -> { // BLOCK + do// COMPOSITE { + z = z.plus(other = 13) + // } while (false) + } + } + { // BLOCK + val tmp_4: Int = z + when { + EQEQ(arg0 = tmp_4, arg1 = 1) -> { // BLOCK + { // BLOCK + val tmp_5: IntIterator = 0.rangeTo(other = 14).iterator() + while (tmp_5.hasNext()) { // BLOCK + val i: Int = tmp_5.next() + z = z.plus(other = i) + } + } + } + else -> { // BLOCK + { // BLOCK + val tmp_6: IntIterator = 0.rangeTo(other = 15).iterator() + while (tmp_6.hasNext()) { // BLOCK + val i: Int = tmp_6.next() + z = z.plus(other = i) + } + } + } + } + } + { // BLOCK + val tmp_7: Int = z + when { + EQEQ(arg0 = tmp_7, arg1 = 1) -> { // BLOCK + val tmp_8: IntIterator = 0.rangeTo(other = 16).iterator() + while (tmp_8.hasNext()) { // BLOCK + val i: Int = tmp_8.next() + z = z.plus(other = i) + } + } + else -> { // BLOCK + val tmp_9: IntIterator = 0.rangeTo(other = 17).iterator() + while (tmp_9.hasNext()) { // BLOCK + val i: Int = tmp_9.next() + z = z.plus(other = i) + } + } + } + } + { // BLOCK + val tmp_10: Int = z + when { + EQEQ(arg0 = tmp_10, arg1 = 1) -> { // BLOCK + while (false) z = z.plus(other = 18) + } + else -> { // BLOCK + while (false) z = z.plus(other = 19) + } + } + } + { // BLOCK + val tmp_11: Int = z + when { + EQEQ(arg0 = tmp_11, arg1 = 1) -> while (false) z = z.plus(other = 20) + else -> while (false) z = z.plus(other = 21) + } + } + { // BLOCK + val tmp_12: Int = z + when { + EQEQ(arg0 = tmp_12, arg1 = 1) -> { // BLOCK + { // BLOCK + do// COMPOSITE { + z = z.plus(other = 22) + // } while (false) + } + } + else -> { // BLOCK + { // BLOCK + do// COMPOSITE { + z = z.plus(other = 23) + // } while (false) + } + } + } + } + { // BLOCK + val tmp_13: Int = z + when { + EQEQ(arg0 = tmp_13, arg1 = 1) -> { // BLOCK + do// COMPOSITE { + z = z.plus(other = 24) + // } while (false) + } + else -> { // BLOCK + do// COMPOSITE { + z = z.plus(other = 25) + // } while (false) + } + } + } +} diff --git a/compiler/testData/ir/irText/expressions/ifWithLoop.sig.kt.txt b/compiler/testData/ir/irText/expressions/ifWithLoop.sig.kt.txt new file mode 100644 index 00000000000..c61bfa16655 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/ifWithLoop.sig.kt.txt @@ -0,0 +1,5 @@ +// CHECK: +// Mangled name: #topLevelMethod(){} +// Public signature: /topLevelMethod|3993481242130118189[0] +// Public signature debug description: topLevelMethod(){} +fun topLevelMethod(): Unit diff --git a/compiler/testData/ir/irText/expressions/kt27933.fir.ir.txt b/compiler/testData/ir/irText/expressions/kt27933.fir.ir.txt index 92613d9d1db..26ed2acc007 100644 --- a/compiler/testData/ir/irText/expressions/kt27933.fir.ir.txt +++ b/compiler/testData/ir/irText/expressions/kt27933.fir.ir.txt @@ -12,20 +12,18 @@ FILE fqName: fileName:/kt27933.kt then: BLOCK type=kotlin.Unit origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: BLOCK type=kotlin.Unit origin=null - SET_VAR 'var r: kotlin.String declared in .box' type=kotlin.Unit origin=EQ - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null - $this: GET_VAR 'var r: kotlin.String declared in .box' type=kotlin.String origin=null - other: CONST String type=kotlin.String value="O" + then: SET_VAR 'var r: kotlin.String declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: GET_VAR 'var r: kotlin.String declared in .box' type=kotlin.String origin=null + other: CONST String type=kotlin.String value="O" WHEN type=kotlin.Unit origin=IF BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'var r: kotlin.String declared in .box' type=kotlin.String origin=null arg1: CONST String type=kotlin.String value="O" - then: BLOCK type=kotlin.Unit origin=null - SET_VAR 'var r: kotlin.String declared in .box' type=kotlin.Unit origin=EQ - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null - $this: GET_VAR 'var r: kotlin.String declared in .box' type=kotlin.String origin=null - other: CONST String type=kotlin.String value="K" + then: SET_VAR 'var r: kotlin.String declared in .box' type=kotlin.Unit origin=EQ + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String declared in kotlin.String' type=kotlin.String origin=null + $this: GET_VAR 'var r: kotlin.String declared in .box' type=kotlin.String origin=null + other: CONST String type=kotlin.String value="K" RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' GET_VAR 'var r: kotlin.String declared in .box' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/expressions/kt27933.fir.kt.txt b/compiler/testData/ir/irText/expressions/kt27933.fir.kt.txt index d1e3e1b00d5..470ac8cc65c 100644 --- a/compiler/testData/ir/irText/expressions/kt27933.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/kt27933.fir.kt.txt @@ -3,14 +3,10 @@ fun box(): String { when { EQEQ(arg0 = r, arg1 = "").not() -> { // BLOCK } - else -> { // BLOCK - r = r.plus(other = "O") - } + else -> r = r.plus(other = "O") } when { - EQEQ(arg0 = r, arg1 = "O") -> { // BLOCK - r = r.plus(other = "K") - } + EQEQ(arg0 = r, arg1 = "O") -> r = r.plus(other = "K") } return r } diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java index 37fbb228977..10c571ce649 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/ClassicJvmIrTextTestGenerated.java @@ -1622,6 +1622,24 @@ public class ClassicJvmIrTextTestGenerated extends AbstractClassicJvmIrTextTest runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java index a7ceeace311..3bd79a3d302 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/klib/KlibIrTextTestCaseGenerated.java @@ -1349,6 +1349,21 @@ public class KlibIrTextTestCaseGenerated extends AbstractKlibIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { runTest("compiler/testData/ir/irText/expressions/implicitCastInReturnFromConstructor.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java index dbcf1cf38ac..dc5a9d2a7b4 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirLightTreeJsIrTextTestGenerated.java @@ -1484,6 +1484,24 @@ public class FirLightTreeJsIrTextTestGenerated extends AbstractFirLightTreeJsIrT runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java index 6f721851e5c..44b43a1da78 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirPsiJsIrTextTestGenerated.java @@ -1484,6 +1484,24 @@ public class FirPsiJsIrTextTestGenerated extends AbstractFirPsiJsIrTextTest { runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java index 3ac1350c630..dc9c89c8933 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/ClassicJsIrTextTestGenerated.java @@ -1484,6 +1484,24 @@ public class ClassicJsIrTextTestGenerated extends AbstractClassicJsIrTextTest { runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/ClassicNativeIrTextTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/ClassicNativeIrTextTestGenerated.java index bd21754eec4..c87e71b8942 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/ClassicNativeIrTextTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/ClassicNativeIrTextTestGenerated.java @@ -1484,6 +1484,24 @@ public class ClassicNativeIrTextTestGenerated extends AbstractClassicNativeIrTex runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirLightTreeNativeIrTextTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirLightTreeNativeIrTextTestGenerated.java index e924f108212..906f993b2d1 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirLightTreeNativeIrTextTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirLightTreeNativeIrTextTestGenerated.java @@ -1484,6 +1484,24 @@ public class FirLightTreeNativeIrTextTestGenerated extends AbstractFirLightTreeN runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception { diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirPsiNativeIrTextTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirPsiNativeIrTextTestGenerated.java index 72c4083cda1..b679cb5523b 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirPsiNativeIrTextTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/irtext/FirPsiNativeIrTextTestGenerated.java @@ -1484,6 +1484,24 @@ public class FirPsiNativeIrTextTestGenerated extends AbstractFirPsiNativeIrTextT runTest("compiler/testData/ir/irText/expressions/ifElseIf.kt"); } + @Test + @TestMetadata("ifWithArrayOperation.kt") + public void testIfWithArrayOperation() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithArrayOperation.kt"); + } + + @Test + @TestMetadata("ifWithAssignment.kt") + public void testIfWithAssignment() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithAssignment.kt"); + } + + @Test + @TestMetadata("ifWithLoop.kt") + public void testIfWithLoop() throws Exception { + runTest("compiler/testData/ir/irText/expressions/ifWithLoop.kt"); + } + @Test @TestMetadata("implicitCastInReturnFromConstructor.kt") public void testImplicitCastInReturnFromConstructor() throws Exception {