Exhaustive whens without else and 'Nothing' as the result are considered 'implicit exhaustive'
This commit is contained in:
committed by
Mikhail Glukhikh
parent
d62d7dd84f
commit
b93894953d
@@ -2,11 +2,11 @@ enum class Color { RED, GREEN, BLUE }
|
||||
|
||||
fun foo(arr: Array<Color>): Color {
|
||||
loop@ for (color in arr) {
|
||||
when (color) {
|
||||
<!DEBUG_INFO_IMPLICIT_EXHAUSTIVE!>when (color) {
|
||||
Color.RED -> return color
|
||||
Color.GREEN -> break@loop
|
||||
Color.BLUE -> if (arr.size == 1) return color else continue@loop
|
||||
}
|
||||
}<!>
|
||||
// Unreachable
|
||||
<!UNREACHABLE_CODE!>return Color.BLUE<!>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user