Open
Description
sealed class BaseType<A> {}
class ChildA<A> extends BaseType<A> {}
class ChildB<A, B> extends BaseType<A> {}
test<A>(BaseType<A> a) => switch (a) {
ChildA() => "ChildA",
ChildB() => "ChildB",
};
This fails with a compilation error:
The type 'BaseType<A>' is not exhaustively matched by the switch cases since it doesn't match 'ChildB<dynamic, dynamic>()'.
Try adding a wildcard pattern or cases that match 'ChildB<dynamic, dynamic>()'. dart(non_exhaustive_switch_expression)
I'm not sure why it asks for ChildB<dynamic, dynamic>()
.
I don't want to use that as I'll loose type information.
I expect the matched type ChildB<A, dynamic>
to be enough.
Tested using Dart version 3.2.6