isn't this decidable somehow? ```sealed interface ...
# getting-started
m
isn't this decidable somehow?
Copy code
sealed interface Foo
sealed interface Bar
sealed interface Thing {
    object ONE : Thing, Foo
    object TWO : Thing, Bar
}

fun main(){
    val thing: Thing = Thing.ONE
    if(thing is Foo && thing is Bar){
        // This can´t happen
    }
}
c
Kotlin when statements are exhaustive over sealed types; if statements are not.
why do you believe that can’t happen? an object can implement multiple interfaces; there’s nothing preventing implementation of Foo and Bar.
Copy code
sealed interface Foo
sealed interface Bar
sealed interface Thing {
    object ONE : Thing, Foo
    object TWO : Thing, Bar
    object THREE : Thing, Foo, Bar
}

fun main(){
    val thing: Thing = Thing.ONE
    if(thing is Foo && thing is Bar){
       
    }

}
j
@Chris Lee these interfaces are sealed, so adding
object THREE
could make the code path viable, it still doesn't mean that the compiler cannot detect dead code without it (in theory)
m
@Joffrey Yeah, I feel like, since
when
knows what a foo is in its statement and knows how to fill in the rest, I feel like an if on on these two disjoint sets would be an "always false" statement