psi2ir: Empty 'if' branches have type 'kotlin.Unit'
This commit is contained in:
+38
-1
@@ -21,4 +21,41 @@ FILE fqName:<root> fileName:/ifElseIf.kt
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
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
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches1' type=kotlin.Boolean origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=true
|
||||
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
|
||||
FUN name:testEmptyBranches2 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches2' type=kotlin.Boolean origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=true
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches2' type=kotlin.Boolean origin=null
|
||||
then: CONST Boolean type=kotlin.Boolean value=true
|
||||
FUN name:testEmptyBranches3 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches3' type=kotlin.Boolean origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=true
|
||||
|
||||
+18
-3
@@ -1,4 +1,19 @@
|
||||
fun test(i: Int) =
|
||||
if (i > 0) 1
|
||||
else if (i < 0) -1
|
||||
else 0
|
||||
if (i > 0) 1
|
||||
else if (i < 0) -1
|
||||
else 0
|
||||
|
||||
fun testEmptyBranches1(flag: Boolean) {
|
||||
if (flag) ; else true
|
||||
if (flag) true else;
|
||||
}
|
||||
|
||||
fun testEmptyBranches2(flag: Boolean) {
|
||||
if (flag) {} else true
|
||||
if (flag) true else {}
|
||||
}
|
||||
|
||||
fun testEmptyBranches3(flag: Boolean) {
|
||||
if (flag)
|
||||
else true
|
||||
}
|
||||
@@ -17,3 +17,49 @@ FILE fqName:<root> fileName:/ifElseIf.kt
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
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
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches1' type=kotlin.Boolean origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: 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
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches1' type=kotlin.Boolean origin=null
|
||||
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
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
WHEN type=kotlin.Any origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches2' type=kotlin.Boolean origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CONST Boolean type=kotlin.Boolean value=true
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
WHEN type=kotlin.Any origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches2' type=kotlin.Boolean origin=null
|
||||
then: CONST Boolean type=kotlin.Boolean value=true
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: BLOCK type=kotlin.Unit origin=null
|
||||
FUN name:testEmptyBranches3 visibility:public modality:FINAL <> (flag:kotlin.Boolean) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:flag index:0 type:kotlin.Boolean
|
||||
BLOCK_BODY
|
||||
WHEN type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: GET_VAR 'flag: kotlin.Boolean declared in <root>.testEmptyBranches3' type=kotlin.Boolean origin=null
|
||||
then: BLOCK type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: 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
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ FILE fqName:<root> fileName:/kt27933.kt
|
||||
$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 'var r: kotlin.String [var] declared in <root>.box' type=kotlin.String origin=null
|
||||
arg1: CONST String type=kotlin.String value=""
|
||||
then: BLOCK type=kotlin.Nothing origin=IF
|
||||
then: BLOCK type=kotlin.Unit origin=IF
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: SET_VAR 'var r: kotlin.String [var] declared in <root>.box' type=kotlin.Unit origin=PLUSEQ
|
||||
|
||||
Reference in New Issue
Block a user