-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work ondart-model-analyzer-specIssues with the analyzer's implementation of the language specIssues with the analyzer's implementation of the language specdevexp-warningIssues with the analyzer's Warning codesIssues with the analyzer's Warning codeslegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
Description
Consider the following code:
sealed class A {}
class B extends A {}
class C extends A {}
String f(A x) {
switch (x) {
case B():
return 'B';
case C():
return 'C';
case _:
return 'Some other subclass of A (impossible)';
}
}
This produces the analyzer hint:
info - test.dart:11:5 - This case is covered by the previous cases. Try removing the case clause, or restructuring the preceding patterns. - unreachable_switch_case
Which seems reasonable.
However, if I replace case _:
with default:
, then the analyzer doesn't report any issues.
This seems wrong to me. case _:
and default:
have exactly the same runtime behavior. They should lead to the same hints.
lucavenir, scheglov, kevmoo and FMorschel
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work ondart-model-analyzer-specIssues with the analyzer's implementation of the language specIssues with the analyzer's implementation of the language specdevexp-warningIssues with the analyzer's Warning codesIssues with the analyzer's Warning codeslegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)