[FIR2IR] Don't replace while loop and when branch body blocks with single expression. Skip some empty blocks.

https://youtrack.jetbrains.com/issue/KT-60264/K2-while-loop-body-block-sometimes-replaced-with-single-expression

Merge-request: KT-MR-12035
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
Vladimir Sukharev
2023-09-18 15:27:19 +00:00
committed by Space Team
parent f4df4f8007
commit 9a2eff6487
61 changed files with 601 additions and 1102 deletions
@@ -67,7 +67,6 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val]
CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT
$this: GET_VAR 'val tmp_2: kotlin.collections.Iterator<kotlin.String> declared in <root>.test3' type=kotlin.collections.Iterator<kotlin.String> origin=null
BLOCK type=kotlin.Unit origin=null
FUN name:test4 visibility:public modality:FINAL <> (ss:kotlin.collections.List<kotlin.String>?) returnType:kotlin.Unit
VALUE_PARAMETER name:ss index:0 type:kotlin.collections.List<kotlin.String>?
BLOCK_BODY
@@ -96,7 +95,6 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
VAR FOR_LOOP_VARIABLE name:s type:kotlin.String [val]
CALL 'public abstract fun next (): T of kotlin.collections.Iterator declared in kotlin.collections.Iterator' type=kotlin.String origin=FOR_LOOP_NEXT
$this: GET_VAR 'val tmp_4: kotlin.collections.Iterator<kotlin.String> declared in <root>.test4' type=kotlin.collections.Iterator<kotlin.String> origin=null
BLOCK type=kotlin.Unit origin=null
FUN name:test5 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
VAR name:i type:kotlin.Int [var]
@@ -114,11 +112,12 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
CONST Int type=kotlin.Int value=0
BLOCK type=kotlin.Unit origin=null
DO_WHILE label=Inner origin=DO_WHILE_LOOP
body: BLOCK type=kotlin.Int origin=null
SET_VAR 'var j: kotlin.Int declared in <root>.test5' type=kotlin.Unit origin=PREFIX_INCR
CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'var j: kotlin.Int declared in <root>.test5' type=kotlin.Int origin=null
GET_VAR 'var j: kotlin.Int declared in <root>.test5' type=kotlin.Int origin=null
body: COMPOSITE type=kotlin.Unit origin=null
BLOCK type=kotlin.Int origin=null
SET_VAR 'var j: kotlin.Int declared in <root>.test5' type=kotlin.Unit origin=PREFIX_INCR
CALL 'public final fun inc (): kotlin.Int declared in kotlin.Int' type=kotlin.Int origin=null
$this: GET_VAR 'var j: kotlin.Int declared in <root>.test5' type=kotlin.Int origin=null
GET_VAR 'var j: kotlin.Int declared in <root>.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