Fix KT-24804 PSI2IR Crashes on loop with two labels

This commit is contained in:
Dmitry Petrov
2018-12-06 17:03:01 +03:00
parent 6f97db81c8
commit 0561cb6c0d
5 changed files with 90 additions and 20 deletions
@@ -134,4 +134,3 @@ FILE fqName:<root> fileName:/breakContinueInLoopHeader.kt
arg0: GET_VAR 'i: Int' type=kotlin.Int origin=null
arg1: CONST Int type=kotlin.Int value=3
then: BREAK label=null loop.label=Outer
+17
View File
@@ -0,0 +1,17 @@
inline fun foo() = false
fun run(x: Boolean, y: Boolean): String {
var z = 10
l1@ l2@ do {
z += 1
if (z > 100) return "NOT_OK"
if (x) continue@l1
if (y) continue@l2
} while(foo())
return "OK"
}
fun box(): String {
return run(true, true)
}
+42
View File
@@ -0,0 +1,42 @@
FILE fqName:<root> fileName:/kt24804.kt
FUN name:foo visibility:public modality:FINAL <> () returnType:kotlin.Boolean flags:inline
BLOCK_BODY
RETURN type=kotlin.Nothing from='foo(): Boolean'
CONST Boolean type=kotlin.Boolean value=false
FUN name:run visibility:public modality:FINAL <> (x:kotlin.Boolean, y:kotlin.Boolean) returnType:kotlin.String flags:
VALUE_PARAMETER name:x index:0 type:kotlin.Boolean flags:
VALUE_PARAMETER name:y index:1 type:kotlin.Boolean flags:
BLOCK_BODY
VAR name:z type:kotlin.Int flags:var
CONST Int type=kotlin.Int value=10
BLOCK type=kotlin.Unit origin=null
DO_WHILE label=l2 origin=DO_WHILE_LOOP
body: COMPOSITE type=kotlin.Unit origin=null
SET_VAR 'z: Int' type=kotlin.Unit origin=PLUSEQ
CALL 'plus(Int): Int' type=kotlin.Int origin=PLUSEQ
$this: GET_VAR 'z: Int' type=kotlin.Int origin=PLUSEQ
other: CONST Int type=kotlin.Int value=1
WHEN type=kotlin.Unit origin=null
BRANCH
if: CALL 'greater(Int, Int): Boolean' type=kotlin.Boolean origin=GT
arg0: GET_VAR 'z: Int' type=kotlin.Int origin=null
arg1: CONST Int type=kotlin.Int value=100
then: RETURN type=kotlin.Nothing from='run(Boolean, Boolean): String'
CONST String type=kotlin.String value="NOT_OK"
WHEN type=kotlin.Unit origin=null
BRANCH
if: GET_VAR 'value-parameter x: Boolean' type=kotlin.Boolean origin=null
then: CONTINUE label=l2 loop.label=l2
WHEN type=kotlin.Unit origin=null
BRANCH
if: GET_VAR 'value-parameter y: Boolean' type=kotlin.Boolean origin=null
then: CONTINUE label=l2 loop.label=l2
condition: CALL 'foo(): Boolean' type=kotlin.Boolean origin=null
RETURN type=kotlin.Nothing from='run(Boolean, Boolean): String'
CONST String type=kotlin.String value="OK"
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String flags:
BLOCK_BODY
RETURN type=kotlin.Nothing from='box(): String'
CALL 'run(Boolean, Boolean): String' type=kotlin.String origin=null
x: CONST Boolean type=kotlin.Boolean value=true
y: CONST Boolean type=kotlin.Boolean value=true