FIR: Support exhaustive whens on subjects of intersection type

This commit is contained in:
Denis.Zharkov
2021-06-08 17:59:01 +03:00
parent c8b9a3a6f0
commit 2653565f56
11 changed files with 262 additions and 11 deletions
@@ -0,0 +1,42 @@
// !CHECK_TYPE
sealed class A {
class A1 : A()
class A2 : A()
}
sealed class B {
class B1 : B()
class B2 : B()
}
fun foo(a: A) {
if (a !is B) return
when (a) {
is A.A1 -> ""
is A.A2 -> "v"
}.length
when (a) {
is A.A1 -> ""
is A.A2 -> "v"
}.length // OK
when (a) {
is A.A1 -> ""
is A.A2 -> "v"
is B.B1 -> "..." // should be warning: unreachable code
}.length // OK
when (a) {
is A.A1 -> ""
is B.B1 -> "..."
is A.A2 -> "v"
}.length // OK
<!NO_ELSE_IN_WHEN!>when<!> (a) {
is A.A1 -> ""
is B.B1 -> "..."
}.<!UNRESOLVED_REFERENCE!>length<!>
}