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.
14 lines
227 B
Kotlin
Vendored
14 lines
227 B
Kotlin
Vendored
enum class MyEnum {
|
|
A, B
|
|
}
|
|
|
|
fun foo(x: MyEnum?): Int {
|
|
val y: Int
|
|
// See KT-6046: y is always initialized
|
|
when (x) {
|
|
MyEnum.A -> y = 1
|
|
MyEnum.B -> y = 2
|
|
null -> y = 0
|
|
}
|
|
return y
|
|
} |