[FE 1.0] Record USED_AS_EXPRESSION for unreachable CFG nodes

^KT-48708 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-09-13 11:02:01 +03:00
committed by teamcityserver
parent 8464b15d27
commit d390f881c8
10 changed files with 119 additions and 9 deletions
@@ -0,0 +1,13 @@
fun test(b: Boolean) {
val x: Int = when {
b -> 3
else -> { // BLOCK
throw Exception()
0
}
}
takeInt(x = x)
}
fun takeInt(x: Int) {
}
+20
View File
@@ -0,0 +1,20 @@
FILE fqName:<root> fileName:/kt48708.kt
FUN name:test visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.Unit
VALUE_PARAMETER name:b index:0 type:kotlin.Boolean
BLOCK_BODY
VAR name:x type:kotlin.Int [val]
WHEN type=kotlin.Int origin=IF
BRANCH
if: GET_VAR 'b: kotlin.Boolean declared in <root>.test' type=kotlin.Boolean origin=null
then: CONST Int type=kotlin.Int value=3
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=kotlin.Int origin=null
THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.Exception' type=java.lang.Exception origin=null
CONST Int type=kotlin.Int value=0
CALL 'public final fun takeInt (x: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
x: GET_VAR 'val x: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
FUN name:takeInt visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Int
BLOCK_BODY
+13
View File
@@ -0,0 +1,13 @@
// ISSUE: KT-48708
fun test(b: Boolean) {
val x = if (b) {
3
} else {
throw Exception()
0
}
takeInt(x)
}
fun takeInt(x: Int) {}
+15
View File
@@ -0,0 +1,15 @@
fun test(b: Boolean) {
val x: Int = when {
b -> { // BLOCK
3
}
else -> { // BLOCK
throw Exception()
0
}
}
takeInt(x = x)
}
fun takeInt(x: Int) {
}
+21
View File
@@ -0,0 +1,21 @@
FILE fqName:<root> fileName:/kt48708.kt
FUN name:test visibility:public modality:FINAL <> (b:kotlin.Boolean) returnType:kotlin.Unit
VALUE_PARAMETER name:b index:0 type:kotlin.Boolean
BLOCK_BODY
VAR name:x type:kotlin.Int [val]
WHEN type=kotlin.Int origin=IF
BRANCH
if: GET_VAR 'b: kotlin.Boolean declared in <root>.test' type=kotlin.Boolean origin=null
then: BLOCK type=kotlin.Int origin=null
CONST Int type=kotlin.Int value=3
BRANCH
if: CONST Boolean type=kotlin.Boolean value=true
then: BLOCK type=kotlin.Int origin=null
THROW type=kotlin.Nothing
CONSTRUCTOR_CALL 'public constructor <init> () declared in java.lang.Exception' type=java.lang.Exception origin=null
CONST Int type=kotlin.Int value=0
CALL 'public final fun takeInt (x: kotlin.Int): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
x: GET_VAR 'val x: kotlin.Int [val] declared in <root>.test' type=kotlin.Int origin=null
FUN name:takeInt visibility:public modality:FINAL <> (x:kotlin.Int) returnType:kotlin.Unit
VALUE_PARAMETER name:x index:0 type:kotlin.Int
BLOCK_BODY