Implicit exhaustive whens now have exception in else branch #KT-8700 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
011a9f23b9
commit
7d6ccc40c2
@@ -0,0 +1,14 @@
|
||||
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"
|
||||
Reference in New Issue
Block a user