Files
kotlin-fork/compiler/testData/diagnostics/tests/when/intersectionExhaustivenessComplex.kt
T
2021-07-13 10:35:01 +03:00

43 lines
996 B
Kotlin
Vendored

// !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 (<!USELESS_IS_CHECK!>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
}