[FIR2IR] Don't emit empty body of while/do_while loop
Merge-request: KT-MR-12283 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
5b4409e34c
commit
e9d4de658d
@@ -18,7 +18,6 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val tmp_0: kotlin.Boolean? declared in <root>.test1' type=kotlin.Boolean? origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
FUN name:test2 visibility:public modality:FINAL <> (c:kotlin.Boolean?) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:c index:0 type:kotlin.Boolean?
|
||||
BLOCK_BODY
|
||||
@@ -38,7 +37,6 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val tmp_1: kotlin.Boolean? declared in <root>.test2' type=kotlin.Boolean? origin=null
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
FUN name:test3 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
|
||||
|
||||
+2
-4
@@ -6,8 +6,7 @@ fun test1(c: Boolean?) {
|
||||
EQEQ(arg0 = <elvis>, arg1 = null) -> break@L
|
||||
else -> <elvis>
|
||||
}
|
||||
}) { // BLOCK
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +18,7 @@ fun test2(c: Boolean?) {
|
||||
EQEQ(arg0 = <elvis>, arg1 = null) -> continue@L
|
||||
else -> <elvis>
|
||||
}
|
||||
}) { // BLOCK
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
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 declared in <root>.test' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
body: BLOCK type=kotlin.Unit origin=null
|
||||
WHILE label=null origin=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 declared in <root>.test' type=kotlin.Int origin=null
|
||||
@@ -33,10 +32,15 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
GET_VAR 'val tmp_1: kotlin.Int declared in <root>.test' type=kotlin.Int origin=null
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: COMPOSITE type=kotlin.Unit 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 declared in <root>.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: COMPOSITE type=kotlin.Unit 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 declared in <root>.test' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=7
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: BLOCK type=kotlin.Int origin=POSTFIX_INCR
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
fun test() {
|
||||
var x: Int = 0
|
||||
while (less(arg0 = x, arg1 = 0)) { // BLOCK
|
||||
}
|
||||
while (less(arg0 = x, arg1 = 0))
|
||||
while (less(arg0 = x, arg1 = 5)) { // BLOCK
|
||||
val <unary>: Int = x
|
||||
x = <unary>.inc()
|
||||
@@ -14,9 +13,12 @@ fun test() {
|
||||
<unary>
|
||||
}
|
||||
}
|
||||
{ // BLOCK
|
||||
do while (less(arg0 = x, arg1 = 0))
|
||||
}
|
||||
{ // BLOCK
|
||||
do// COMPOSITE {
|
||||
// } while (less(arg0 = x, arg1 = 0))
|
||||
// } while (less(arg0 = x, arg1 = 7))
|
||||
}
|
||||
{ // BLOCK
|
||||
do{ // BLOCK
|
||||
|
||||
@@ -37,6 +37,12 @@ FILE fqName:<root> fileName:/whileDoWhile.kt
|
||||
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 declared in <root>.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: COMPOSITE type=kotlin.Unit 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 declared in <root>.test' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=7
|
||||
BLOCK type=kotlin.Unit origin=null
|
||||
DO_WHILE label=null origin=DO_WHILE_LOOP
|
||||
body: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
|
||||
@@ -4,6 +4,7 @@ fun test() {
|
||||
while (x < 5) x++
|
||||
while (x < 10) { x++ }
|
||||
do while (x < 0)
|
||||
do {} while (x < 7)
|
||||
do x++ while (x < 15)
|
||||
do { x ++ } while (x < 20)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,10 @@ fun test() {
|
||||
{ // BLOCK
|
||||
do while (less(arg0 = x, arg1 = 0))
|
||||
}
|
||||
{ // BLOCK
|
||||
do// COMPOSITE {
|
||||
// } while (less(arg0 = x, arg1 = 7))
|
||||
}
|
||||
{ // BLOCK
|
||||
do{ // BLOCK
|
||||
val tmp2: Int = x
|
||||
|
||||
Reference in New Issue
Block a user