b4a5eec5f4
As shown in KT-44412 (or KT-45319 or KT-17728):
```
fun test5() {
var i = 0
Outer@while (true) {
++i
var j = 0
Inner@do {
++j
} while (if (j >= 3) false else break) // break@Inner
if (i == 3) break
}
}
```
To properly set the loop target for `break` in do-while loop condition,
the loop target for that do-while loop should be ready before parsing
the loop condition.
Previously, Raw FIR loop building configures loop target after visiting
loop conditions. This commit splits the configuration and lets the
builders prepare the loop target for do-while loop only.
81 lines
1.6 KiB
Plaintext
Vendored
81 lines
1.6 KiB
Plaintext
Vendored
fun test1(c: Boolean?) {
|
|
L@ while (true) { // BLOCK
|
|
L2@ while ({ // BLOCK
|
|
val <elvis>: Boolean? = c
|
|
when {
|
|
EQEQ(arg0 = <elvis>, arg1 = null) -> break@L
|
|
else -> <elvis>
|
|
}
|
|
}) { // BLOCK
|
|
}
|
|
}
|
|
}
|
|
|
|
fun test2(c: Boolean?) {
|
|
L@ while (true) { // BLOCK
|
|
L2@ while ({ // BLOCK
|
|
val <elvis>: Boolean? = c
|
|
when {
|
|
EQEQ(arg0 = <elvis>, arg1 = null) -> continue@L
|
|
else -> <elvis>
|
|
}
|
|
}) { // BLOCK
|
|
}
|
|
}
|
|
}
|
|
|
|
fun test3(ss: List<String>?) {
|
|
L@ while (true) { // BLOCK
|
|
{ // BLOCK
|
|
val <iterator>: Iterator<String> = { // BLOCK
|
|
val <elvis>: List<String>? = ss
|
|
when {
|
|
EQEQ(arg0 = <elvis>, arg1 = null) -> continue@L
|
|
else -> <elvis>
|
|
}
|
|
}.iterator()
|
|
L2@ while (<iterator>.hasNext()) { // BLOCK
|
|
val s: String = <iterator>.next()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fun test4(ss: List<String>?) {
|
|
L@ while (true) { // BLOCK
|
|
{ // BLOCK
|
|
val <iterator>: Iterator<String> = { // BLOCK
|
|
val <elvis>: List<String>? = ss
|
|
when {
|
|
EQEQ(arg0 = <elvis>, arg1 = null) -> break@L
|
|
else -> <elvis>
|
|
}
|
|
}.iterator()
|
|
L2@ while (<iterator>.hasNext()) { // BLOCK
|
|
val s: String = <iterator>.next()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
fun test5() {
|
|
var i: Int = 0
|
|
Outer@ while (true) { // BLOCK
|
|
i = i.inc()
|
|
i /*~> Unit */
|
|
var j: Int = 0
|
|
{ // BLOCK
|
|
Inner@ do// COMPOSITE {
|
|
j = j.inc()
|
|
j
|
|
// } while (when {
|
|
greaterOrEqual(arg0 = j, arg1 = 3) -> false
|
|
else -> break@Inner
|
|
})
|
|
}
|
|
when {
|
|
EQEQ(arg0 = i, arg1 = 3) -> break@Outer
|
|
}
|
|
}
|
|
}
|