Files
kotlin-fork/compiler/testData/ir/irText/expressions/breakContinueInLoopHeader.fir.kt.txt
T
Vladimir Sukharev e9d4de658d [FIR2IR] Don't emit empty body of while/do_while loop
Merge-request: KT-MR-12283
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-09-20 10:06:00 +00:00

84 lines
1.7 KiB
Kotlin
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>
}
})
}
}
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>
}
})
}
}
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
{ // BLOCK
i = i.inc()
i
} /*~> Unit */
var j: Int = 0
{ // BLOCK
Inner@ do// COMPOSITE {
{ // BLOCK
j = j.inc()
j
}
// } while (when {
greaterOrEqual(arg0 = j, arg1 = 3) -> false
else -> break@Inner
})
}
when {
EQEQ(arg0 = i, arg1 = 3) -> break@Outer
}
}
}