FIR: allow no else branch for when on Nothing(?)

This commit is contained in:
Tianyu Geng
2021-07-26 15:02:22 -07:00
committed by teamcityserver
parent e242ad955b
commit f737d8002e
8 changed files with 69 additions and 2 deletions
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNREACHABLE_CODE
// exhaustive
fun test1(n: Nothing) = when (n) { }
fun test2(n: Nothing?) = when (n) {
null -> {}
}
// not exhaustive
fun test3(n: Nothing?) = <!NO_ELSE_IN_WHEN!>when<!> (n) {
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNREACHABLE_CODE
// exhaustive
fun test1(n: Nothing) = when (n) { }
fun test2(n: Nothing?) = <!NO_ELSE_IN_WHEN!>when<!> (<!DEBUG_INFO_CONSTANT!>n<!>) {
null -> {}
}
// not exhaustive
fun test3(n: Nothing?) = <!NO_ELSE_IN_WHEN!>when<!> (<!DEBUG_INFO_CONSTANT!>n<!>) {
}
@@ -0,0 +1,3 @@
package
public fun foo(/*0*/ n: kotlin.Nothing, /*1*/ nn: kotlin.Nothing?): kotlin.Unit