if I have a `sealed interface` within a `sealed in...
# android
f
if I have a
sealed interface
within a
sealed interface
I can't have an exhaustive when with the outer
sealed interface
entries (see example in thread). What's the reason for this?
Copy code
sealed interface DeviceType {
    object Phone : DeviceType
    sealed interface Tablet : DeviceType {
        object Small : Tablet
        object Large : Tablet
    }
}

val deviceType: DeviceType = DeviceType.Phone

fun foo() {
    when (deviceType) {
        DeviceType.Phone -> println("Phone")
        DeviceType.Tablet -> println("Tablet") <-- does not compile
    }
}
e
Replace the code inside foo with the following:
Copy code
when (deviceType) {
        DeviceType.Phone -> println("Phone")
        is DeviceType.Tablet -> println("Tablet")
    }
f
thanks, I eventually figured it out, but I appreciate the reply