You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a known shortcoming of the exhaustivness analysis. It doesn't work well with supertypes with type parameters that aren't used. See fx dart-lang/sdk#53486
That means that Final<int, Object?>() is not enough since the space it thinks it needs to exhaust is Mid<Object?, Object?>, and it only exhausts Mid<int, Object?>. That's because it can't figure out the connection between the B of Mid and Base<A>, so it gives up on both type parameters of Mid, and thinks you need to exhaust Mid<Object?, Object?> in order to exhaust Base<int>.
There is room for improvement in that area.
So case Base<int>() is considered reachable, and it does exhaust all of Base<int>. (The algorithm can see that.)
Consider the following sealed hierarchy:
We can then use it with pattern matching like so:
The problem is, this
switch
is considered non-exhaustive.To have the compiler consider the switch as exhaustive, we incorrectly have to change
Final<int, Object?>()
intoFinal<Object?, Object?>()
.This is incorrect, because given
Base<int>
, it is guaranteed that all instances will implementFinal<int, ...>
Removing the intermediary
Mid
class fixes the issue, so it probably has to do with the added level of indirection.The text was updated successfully, but these errors were encountered: