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 1a5daaba533..5cc45b16dfd 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 @@ -728,7 +728,7 @@ class Fir2IrVisitor( private val loopMap = mutableMapOf() override fun visitDoWhileLoop(doWhileLoop: FirDoWhileLoop, data: Any?): IrElement { - return doWhileLoop.convertWithOffsets { startOffset, endOffset -> + val irLoop = doWhileLoop.convertWithOffsets { startOffset, endOffset -> IrDoWhileLoopImpl( startOffset, endOffset, irBuiltIns.unitType, IrStatementOrigin.DO_WHILE_LOOP @@ -742,6 +742,9 @@ class Fir2IrVisitor( }.also { doWhileLoop.accept(implicitCastInserter, it) } + return IrBlockImpl(irLoop.startOffset, irLoop.endOffset, irBuiltIns.unitType).apply { + statements.add(irLoop) + } } override fun visitWhileLoop(whileLoop: FirWhileLoop, data: Any?): IrElement { diff --git a/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.kt.txt b/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.kt.txt index dec2c330262..27c61f6134f 100644 --- a/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.kt.txt +++ b/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.kt.txt @@ -1,5 +1,7 @@ fun foo() { - do// COMPOSITE { - val x: Int = 42 - // } while (EQEQ(arg0 = x, arg1 = 42).not()) + { // BLOCK + do// COMPOSITE { + val x: Int = 42 + // } while (EQEQ(arg0 = x, arg1 = 42).not()) + } } diff --git a/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.txt b/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.txt index 0de30a0fd13..0c6e0955b1d 100644 --- a/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.txt +++ b/compiler/testData/ir/irText/declarations/localVarInDoWhile.fir.txt @@ -1,11 +1,12 @@ FILE fqName: fileName:/localVarInDoWhile.kt FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP - VAR name:x type:kotlin.Int [val] - CONST Int type=kotlin.Int value=42 - condition: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ - $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ - arg0: GET_VAR 'val x: kotlin.Int [val] declared in .foo' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=42 + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + VAR name:x type:kotlin.Int [val] + CONST Int type=kotlin.Int value=42 + condition: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ + $this: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EXCLEQ + arg0: GET_VAR 'val x: kotlin.Int [val] declared in .foo' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=42 diff --git a/compiler/testData/ir/irText/expressions/breakContinue.fir.kt.txt b/compiler/testData/ir/irText/expressions/breakContinue.fir.kt.txt index df1be4e5fc9..55a145d4f9a 100644 --- a/compiler/testData/ir/irText/expressions/breakContinue.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/breakContinue.fir.kt.txt @@ -1,8 +1,12 @@ fun test1() { while (true) break - dobreak while (true) + { // BLOCK + dobreak while (true) + } while (true) continue - docontinue while (true) + { // BLOCK + docontinue while (true) + } } fun test2() { diff --git a/compiler/testData/ir/irText/expressions/breakContinue.fir.txt b/compiler/testData/ir/irText/expressions/breakContinue.fir.txt index dfd2a27515b..ca397655a53 100644 --- a/compiler/testData/ir/irText/expressions/breakContinue.fir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinue.fir.txt @@ -4,15 +4,17 @@ FILE fqName: fileName:/breakContinue.kt WHILE label=null origin=WHILE_LOOP condition: CONST Boolean type=kotlin.Boolean value=true body: BREAK label=null loop.label=null - DO_WHILE label=null origin=DO_WHILE_LOOP - body: BREAK label=null loop.label=null - condition: CONST Boolean type=kotlin.Boolean value=true + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: BREAK label=null loop.label=null + condition: CONST Boolean type=kotlin.Boolean value=true WHILE label=null origin=WHILE_LOOP condition: CONST Boolean type=kotlin.Boolean value=true body: CONTINUE label=null loop.label=null - DO_WHILE label=null origin=DO_WHILE_LOOP - body: CONTINUE label=null loop.label=null - condition: CONST Boolean type=kotlin.Boolean value=true + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: CONTINUE label=null loop.label=null + condition: CONST Boolean type=kotlin.Boolean value=true FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY WHILE label=OUTER origin=WHILE_LOOP diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt index f9ed0b8f326..ef98dad3127 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt @@ -64,13 +64,15 @@ fun test5() { i = i.inc() i /*~> Unit */ var j: Int = 0 - Inner@ do// COMPOSITE { - j = j.inc() - j - // } while (when { - greaterOrEqual(arg0 = j, arg1 = 3) -> false - else -> break@Outer - }) + { // BLOCK + Inner@ do// COMPOSITE { + j = j.inc() + j + // } while (when { + greaterOrEqual(arg0 = j, arg1 = 3) -> false + else -> break@Outer + }) + } when { EQEQ(arg0 = i, arg1 = 3) -> break@Outer } diff --git a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt index 781d8f74a98..b5683d00b43 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.txt @@ -109,21 +109,22 @@ FILE fqName: fileName:/breakContinueInLoopHeader.kt GET_VAR 'var i: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null VAR name:j type:kotlin.Int [var] CONST Int type=kotlin.Int value=0 - DO_WHILE label=Inner origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Int origin=DO_WHILE_LOOP - SET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Unit origin=EQ - CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null - GET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null - condition: WHEN type=kotlin.Boolean origin=IF - BRANCH - if: CALL 'public final fun greaterOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ - arg0: GET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=3 - then: CONST Boolean type=kotlin.Boolean value=false - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: BREAK label=Outer loop.label=Outer + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=Inner origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Int origin=DO_WHILE_LOOP + SET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null + GET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null + condition: WHEN type=kotlin.Boolean origin=IF + BRANCH + if: CALL 'public final fun greaterOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ + arg0: GET_VAR 'var j: kotlin.Int [var] declared in .test5' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=3 + then: CONST Boolean type=kotlin.Boolean value=false + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: BREAK label=Outer loop.label=Outer 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 diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt index 9e334cc43e2..0ecb245c8df 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.kt.txt @@ -24,9 +24,11 @@ fun testBreakWhile() { fun testBreakDoWhile() { var k: Int = 0 - dowhen { - greater(arg0 = k, arg1 = 2) -> break - } while (less(arg0 = k, arg1 = 10)) + { // BLOCK + dowhen { + greater(arg0 = k, arg1 = 2) -> break + } while (less(arg0 = k, arg1 = 10)) + } } fun testContinueFor() { @@ -56,14 +58,16 @@ fun testContinueWhile() { fun testContinueDoWhile() { var k: Int = 0 var s: String = "" - do// COMPOSITE { - k = k.inc() - k /*~> Unit */ - when { - greater(arg0 = k, arg1 = 2) -> continue + { // BLOCK + do// COMPOSITE { + k = k.inc() + k /*~> Unit */ + when { + greater(arg0 = k, arg1 = 2) -> continue + } + s = s.plus(other = k.toString() + ";") + // } while (less(arg0 = k, arg1 = 10)) } - s = s.plus(other = k.toString() + ";") - // } while (less(arg0 = k, arg1 = 10)) when { EQEQ(arg0 = s, arg1 = "1;2;").not() -> throw AssertionError(p0 = s) } diff --git a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.txt b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.txt index 437aedaf264..c5283ed42c7 100644 --- a/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.txt +++ b/compiler/testData/ir/irText/expressions/breakContinueInWhen.fir.txt @@ -47,16 +47,17 @@ FILE fqName: fileName:/breakContinueInWhen.kt BLOCK_BODY VAR name:k type:kotlin.Int [var] CONST Int type=kotlin.Int value=0 - DO_WHILE label=null origin=DO_WHILE_LOOP - body: WHEN type=kotlin.Unit origin=WHEN - BRANCH - if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT - arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: BREAK label=null loop.label=null - condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT - arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=10 + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: BREAK label=null loop.label=null + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testBreakDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 FUN name:testContinueFor visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:xs type:kotlin.IntArray [val] @@ -107,29 +108,30 @@ FILE fqName: fileName:/breakContinueInWhen.kt CONST Int type=kotlin.Int value=0 VAR name:s type:kotlin.String [var] CONST String type=kotlin.String value="" - DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP - SET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Unit origin=EQ - CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null - WHEN type=kotlin.Unit origin=WHEN - BRANCH - if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT - arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=2 - then: CONTINUE label=null loop.label=null - SET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.Unit origin=EQ - CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null - $this: GET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.String origin=null - other: STRING_CONCATENATION type=kotlin.String - CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null - $this: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null - CONST String type=kotlin.String value=";" - condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT - arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=10 + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + SET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + WHEN type=kotlin.Unit origin=WHEN + BRANCH + if: CALL 'public final fun greater (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=2 + then: CONTINUE label=null loop.label=null + SET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.Unit origin=EQ + CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null + $this: GET_VAR 'var s: kotlin.String [var] declared in .testContinueDoWhile' type=kotlin.String origin=null + other: STRING_CONCATENATION type=kotlin.String + CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null + $this: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + CONST String type=kotlin.String value=";" + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var k: kotlin.Int [var] declared in .testContinueDoWhile' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=10 WHEN type=kotlin.Unit origin=IF BRANCH if: CALL 'public final fun not (): kotlin.Boolean [operator] declared in kotlin.Boolean' type=kotlin.Boolean origin=EXCLEQ diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt index 89dd728143d..0791bab07b2 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.kt.txt @@ -12,18 +12,24 @@ fun test() { x = .inc() } - do// COMPOSITE { - // } while (less(arg0 = x, arg1 = 0)) - do{ // BLOCK + { // BLOCK + do// COMPOSITE { + // } while (less(arg0 = x, arg1 = 0)) + } + { // BLOCK + do{ // BLOCK + val : Int = x + x = .inc() + + } while (less(arg0 = x, arg1 = 15)) + } + { // BLOCK + do// COMPOSITE { val : Int = x x = .inc() - } while (less(arg0 = x, arg1 = 15)) - do// COMPOSITE { - val : Int = x - x = .inc() - - // } while (less(arg0 = x, arg1 = 20)) + // } while (less(arg0 = x, arg1 = 20)) + } } fun testSmartcastInCondition() { @@ -32,8 +38,10 @@ fun testSmartcastInCondition() { a is Boolean -> { // BLOCK while (a /*as Boolean */) { // BLOCK } - do// COMPOSITE { - // } while (a /*as Boolean */) + { // BLOCK + do// COMPOSITE { + // } while (a /*as Boolean */) + } } } } diff --git a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.txt b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.txt index 982bbd9e1ea..a0ab96a3e3f 100644 --- a/compiler/testData/ir/irText/expressions/whileDoWhile.fir.txt +++ b/compiler/testData/ir/irText/expressions/whileDoWhile.fir.txt @@ -30,33 +30,36 @@ FILE fqName: fileName:/whileDoWhile.kt CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null $this: GET_VAR 'val tmp_1: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null GET_VAR 'val tmp_1: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null - DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP - condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT - arg0: GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=0 - DO_WHILE label=null origin=DO_WHILE_LOOP - body: BLOCK type=kotlin.Int origin=null - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] - GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null - SET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Unit origin=EQ - CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_2: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null - GET_VAR 'val tmp_2: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null - condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT - arg0: GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=15 - DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Int origin=DO_WHILE_LOOP - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] - GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null - SET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Unit origin=EQ - CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_3: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null - GET_VAR 'val tmp_3: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null - condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT - arg0: GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null - arg1: CONST Int type=kotlin.Int value=20 + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=0 + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: BLOCK type=kotlin.Int origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.Int [val] + GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null + SET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_2: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null + GET_VAR 'val tmp_2: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=15 + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Int origin=DO_WHILE_LOOP + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.Int [val] + GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null + SET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Unit origin=EQ + CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_3: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null + GET_VAR 'val tmp_3: kotlin.Int [val] declared in .test' type=kotlin.Int origin=null + condition: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: GET_VAR 'var x: kotlin.Int [var] declared in .test' type=kotlin.Int origin=null + arg1: CONST Int type=kotlin.Int value=20 FUN name:testSmartcastInCondition visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY VAR name:a type:kotlin.Any? [val] @@ -70,7 +73,8 @@ FILE fqName: fileName:/whileDoWhile.kt condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean GET_VAR 'val a: kotlin.Any? [val] declared in .testSmartcastInCondition' type=kotlin.Any? origin=null body: BLOCK type=kotlin.Unit origin=null - DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP - condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean - GET_VAR 'val a: kotlin.Any? [val] declared in .testSmartcastInCondition' type=kotlin.Any? origin=null + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Unit origin=DO_WHILE_LOOP + condition: TYPE_OP type=kotlin.Boolean origin=IMPLICIT_CAST typeOperand=kotlin.Boolean + GET_VAR 'val a: kotlin.Any? [val] declared in .testSmartcastInCondition' type=kotlin.Any? origin=null diff --git a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt index 871cb1acf00..6d1767f1fcb 100644 --- a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt +++ b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.kt.txt @@ -223,14 +223,16 @@ internal class ArrayMapImpl : ArrayMap { private set protected override fun computeNext() { - do// COMPOSITE { - val : Int = .() - .( = .inc()) - - // } while (when { - less(arg0 = .(), arg1 = .().()) -> EQEQ(arg0 = .().get(index = .()), arg1 = null) - else -> false - }) + { // BLOCK + do// COMPOSITE { + val : Int = .() + .( = .inc()) + + // } while (when { + less(arg0 = .(), arg1 = .().()) -> EQEQ(arg0 = .().get(index = .()), arg1 = null) + else -> false + }) + } when { greaterOrEqual(arg0 = .(), arg1 = .().()) -> .done() else -> .setNext(value = .().get(index = .()) as T) diff --git a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.txt b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.txt index 5ce43cb791f..b4700ceb831 100644 --- a/compiler/testData/ir/irText/firProblems/ArrayMap.fir.txt +++ b/compiler/testData/ir/irText/firProblems/ArrayMap.fir.txt @@ -535,34 +535,35 @@ FILE fqName: fileName:/ArrayMap.kt protected abstract fun computeNext (): kotlin.Unit declared in kotlin.collections.AbstractIterator $this: VALUE_PARAMETER name: type:.ArrayMapImpl.iterator..ArrayMapImpl> BLOCK_BODY - DO_WHILE label=null origin=DO_WHILE_LOOP - body: COMPOSITE type=kotlin.Int origin=DO_WHILE_LOOP - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] - CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY - $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null - CALL 'private final fun (: kotlin.Int): kotlin.Unit declared in .ArrayMapImpl.iterator.' type=kotlin.Unit origin=EQ - $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null - : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_1: kotlin.Int [val] declared in .ArrayMapImpl.iterator..computeNext' type=kotlin.Int origin=null - GET_VAR 'val tmp_1: kotlin.Int [val] declared in .ArrayMapImpl.iterator..computeNext' type=kotlin.Int origin=null - condition: WHEN type=kotlin.Boolean origin=ANDAND - BRANCH - if: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT - arg0: CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY + BLOCK type=kotlin.Unit origin=null + DO_WHILE label=null origin=DO_WHILE_LOOP + body: COMPOSITE type=kotlin.Int origin=DO_WHILE_LOOP + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Int [val] + CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null - arg1: CALL 'public final fun (): kotlin.Int declared in kotlin.Array' type=kotlin.Int origin=GET_PROPERTY - $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY - $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.iterator' type=.ArrayMapImpl.ArrayMapImpl> origin=null - then: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ - arg0: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=kotlin.Any? origin=null - $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY - $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.iterator' type=.ArrayMapImpl.ArrayMapImpl> origin=null - index: CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY + CALL 'private final fun (: kotlin.Int): kotlin.Unit declared in .ArrayMapImpl.iterator.' type=kotlin.Unit origin=EQ + $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null + : CALL 'public final fun inc (): kotlin.Int [operator] declared in kotlin.Int' type=kotlin.Int origin=null + $this: GET_VAR 'val tmp_1: kotlin.Int [val] declared in .ArrayMapImpl.iterator..computeNext' type=kotlin.Int origin=null + GET_VAR 'val tmp_1: kotlin.Int [val] declared in .ArrayMapImpl.iterator..computeNext' type=kotlin.Int origin=null + condition: WHEN type=kotlin.Boolean origin=ANDAND + BRANCH + if: CALL 'public final fun less (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=LT + arg0: CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null - arg1: CONST Null type=kotlin.Nothing? value=null - BRANCH - if: CONST Boolean type=kotlin.Boolean value=true - then: CONST Boolean type=kotlin.Boolean value=false + arg1: CALL 'public final fun (): kotlin.Int declared in kotlin.Array' type=kotlin.Int origin=GET_PROPERTY + $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY + $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.iterator' type=.ArrayMapImpl.ArrayMapImpl> origin=null + then: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ + arg0: CALL 'public final fun get (index: kotlin.Int): T of kotlin.Array [operator] declared in kotlin.Array' type=kotlin.Any? origin=null + $this: CALL 'private final fun (): kotlin.Array declared in .ArrayMapImpl' type=kotlin.Array origin=GET_PROPERTY + $this: GET_VAR ': .ArrayMapImpl.ArrayMapImpl> declared in .ArrayMapImpl.iterator' type=.ArrayMapImpl.ArrayMapImpl> origin=null + index: CALL 'private final fun (): kotlin.Int declared in .ArrayMapImpl.iterator.' type=kotlin.Int origin=GET_PROPERTY + $this: GET_VAR ': .ArrayMapImpl.iterator..ArrayMapImpl> declared in .ArrayMapImpl.iterator..computeNext' type=.ArrayMapImpl.iterator..ArrayMapImpl> origin=null + arg1: CONST Null type=kotlin.Nothing? value=null + BRANCH + if: CONST Boolean type=kotlin.Boolean value=true + then: CONST Boolean type=kotlin.Boolean value=false WHEN type=kotlin.Unit origin=IF BRANCH if: CALL 'public final fun greaterOrEqual (arg0: kotlin.Int, arg1: kotlin.Int): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=GTEQ