Files
kotlin-fork/compiler/testData/codegen/box/when/exhaustiveBreakContinue.kt
T
2019-11-19 11:00:09 +03:00

15 lines
440 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
enum class Color { RED, GREEN, BLUE }
fun foo(arr: Array<Color>): Color {
loop@ for (color in arr) {
when (color) {
Color.RED -> return color
Color.GREEN -> break@loop
Color.BLUE -> if (arr.size == 1) return color else continue@loop
}
}
return Color.GREEN
}
fun box() = if (foo(arrayOf(Color.BLUE, Color.GREEN)) == Color.GREEN) "OK" else "FAIL"