Exhaustiveness check should be able to prefer API instead of non-API witnesses #52682
Labels
analyzer-language-patterns
Issues with analyzer's support for the patterns language feature
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
area-front-end
Use area-front-end for front end / CFE / kernel format related issues.
cfe-messages
Poor/undesirable messaging in errors/warnings emitted by the CFE.
P3
A lower priority bug or feature request
type-enhancement
A request for a change that isn't a bug
See https://dart-review.googlesource.com/c/sdk/+/308520 for the initial question.
With this CL, if we write switch like this:
...and use "Add missing case" twice, it does end up with using implementation classes.
It does not have to, and this API version works as well.
So, here we might have a tooling issue. Either CFE should be enhanced to prefer reporting witnesses that are available in the target code, maybe some filtering, etc. Or the quick fix should climb up. Ideologically, I think it should be CFE. Or the analyzer in a way how it feeds data into CFE, e.g. never return non-API classes that the target package should not use. Not different than how code completion will not suggest non-API classes from other packages.
The text was updated successfully, but these errors were encountered: