Michael de Kaste
10/25/2022, 4:16 PMsealed 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
}
}
Chris Lee
10/25/2022, 4:26 PMChris Lee
10/25/2022, 4:30 PMChris Lee
10/25/2022, 4:31 PMsealed 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){
}
}
Joffrey
10/25/2022, 4:41 PMobject THREE
could make the code path viable, it still doesn't mean that the compiler cannot detect dead code without it (in theory)Michael de Kaste
10/26/2022, 7:18 AMwhen
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