Files
kotlin-fork/compiler/testData/diagnostics/tests/when/whenOnNothing.fir.kt
T
pyos e7b4927b6c FIR: don't emit SENSELESS_NULL_IN_WHEN when value is always null
This case (value is always null) contradicts the error message which says
"Expression under 'when' is never equal to null".
2022-11-10 13:10:58 +00:00

12 lines
246 B
Kotlin
Vendored

// !DIAGNOSTICS: -UNREACHABLE_CODE
// exhaustive
fun test1(n: Nothing) = when (n) { }
fun test2(n: Nothing?) = when (n) {
<!SENSELESS_COMPARISON!>null<!> -> {}
}
// not exhaustive
fun test3(n: Nothing?) = <!NO_ELSE_IN_WHEN!>when<!> (n) {
}