Files
kotlin-fork/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckElse.fir.kt
T

14 lines
342 B
Kotlin
Vendored

// KT-7857: when exhaustiveness does not take previous nullability checks into account
enum class X { A, B }
fun foo(arg: X?): Int {
if (arg == null) {
return 0
}
else {
return when (arg) {
X.A -> 1
X.B -> 2
// else or null branch should not be required here!
}
}
}