0d7f649cc2
Now control flow analyzer knows when is exhaustive. If despite of this all conditions are accidentally false, jump to error is generated. A set of tests (diagnostic, control flow). #KT-5113 Fixed. #KT-6046 Fixed. #KT-1882 Fixed.
15 lines
328 B
Kotlin
Vendored
15 lines
328 B
Kotlin
Vendored
enum class Direction {
|
|
NORTH, SOUTH, WEST, EAST
|
|
}
|
|
|
|
fun foo(dir: Direction): Int {
|
|
val res: Int
|
|
// See KT-6046: res is always initialized
|
|
when (dir) {
|
|
Direction.NORTH -> res = 1
|
|
Direction.SOUTH -> res = 2
|
|
Direction.WEST -> res = 3
|
|
Direction.EAST -> res = 4
|
|
}
|
|
return res
|
|
} |