mattinger
10/24/2022, 9:35 PMsealed interface A {
abstract class AbstractA: A
class B: AbstractA()
class C: AbstractA()
}
fun x(a: A) {
when (a) {
is A.B -> { }
is A.C -> { }
}
}
Has anyone else noticed this before? I get a compile error on the when saying i need to add an implementation for AbstractA, even though it can never be anything but B or C since those are the only concrete implementations.ephemient
10/24/2022, 9:39 PMAbstractA
is not sealed, so anybody could add a class D : A.AbstractA()
outside of your sealed interface, thus you do need to check for itmattinger
10/24/2022, 9:49 PMandylamax
10/24/2022, 9:49 PMsealed interface A {
sealed class AbstractA: A
class B: AbstractA()
class C: AbstractA()
}
fun x(a: A) {
when (a) {
is A.B -> { }
is A.C -> { }
}
}
mattinger
10/24/2022, 9:49 PMmattinger
10/24/2022, 9:50 PM