FIR: Support exhaustive whens on subjects of intersection type
This commit is contained in:
+42
@@ -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
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (<!DEBUG_INFO_SMARTCAST!>a<!>) {
|
||||
is A.A1 -> ""
|
||||
is A.A2 -> "v"
|
||||
}.length
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (<!DEBUG_INFO_SMARTCAST!>a<!>) {
|
||||
is A.A1 -> ""
|
||||
is A.A2 -> "v"
|
||||
}.length // OK
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (<!DEBUG_INFO_SMARTCAST!>a<!>) {
|
||||
is A.A1 -> ""
|
||||
is A.A2 -> "v"
|
||||
is <!INCOMPATIBLE_TYPES!>B.B1<!> -> "..." // should be warning: unreachable code
|
||||
}.length // OK
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (<!DEBUG_INFO_SMARTCAST!>a<!>) {
|
||||
is A.A1 -> ""
|
||||
is <!INCOMPATIBLE_TYPES!>B.B1<!> -> "..."
|
||||
is A.A2 -> "v"
|
||||
}.length // OK
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (<!DEBUG_INFO_SMARTCAST!>a<!>) {
|
||||
is A.A1 -> ""
|
||||
is <!INCOMPATIBLE_TYPES!>B.B1<!> -> "..."
|
||||
}.length
|
||||
}
|
||||
Reference in New Issue
Block a user