RAW FIR: flatten if chains
This commit is contained in:
+8
-10
@@ -9,17 +9,14 @@ FILE fqName:<root> fileName:/ifElseIf.kt
|
||||
arg0: GET_VAR 'i: kotlin.Int declared in <root>.test' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Int type=kotlin.Int value=1
|
||||
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: GET_VAR 'i: kotlin.Int declared in <root>.test' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Int type=kotlin.Int value=-1
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: WHEN type=kotlin.Int origin=IF
|
||||
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: GET_VAR 'i: kotlin.Int declared in <root>.test' type=kotlin.Int origin=null
|
||||
arg1: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Int type=kotlin.Int value=-1
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Int type=kotlin.Int value=0
|
||||
then: CONST Int type=kotlin.Int value=0
|
||||
FUN name:testEmptyBranches1 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean
|
||||
BLOCK_BODY
|
||||
@@ -34,7 +31,8 @@ FILE fqName:<root> fileName:/ifElseIf.kt
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches1' type=kotlin.Boolean origin=null
|
||||
then: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN name:testEmptyBranches2 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean
|
||||
BLOCK_BODY
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
fun test(i: Int): Int {
|
||||
return when {
|
||||
greater(arg0 = i, arg1 = 0) -> 1
|
||||
else -> when {
|
||||
less(arg0 = i, arg1 = 0) -> -1
|
||||
else -> 0
|
||||
}
|
||||
less(arg0 = i, arg1 = 0) -> -1
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +13,7 @@ fun testEmptyBranches1(flag: Boolean) {
|
||||
else -> true
|
||||
} /*~> Unit */
|
||||
when {
|
||||
flag -> true
|
||||
flag -> true /*~> Unit */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user