-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposallinter-status-pendingtype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug
Description
Add warning for Iterable<E>.whereType<T> when T is! E.
I think the static analyzer should warn against such obvious cases:
void main() {
var some = <int>[].whereType<String>(); // no warning here
print(some.isEmpty); // always true
}I expected to have a warning along the lines: Unnecessary Iterable; 'Iterable<int>' can never contain type 'String'...
Why this is useful?
I believe many developers, including myself, relay on the static analyzer when refactoring code by slightly modifying a program so analysis errors/warnings are propagated throughout the codebase to guide the refactoring effort. In such cases, it would be useful to catch the case above, which I came across today.
kevmoo
Metadata
Metadata
Assignees
Labels
P3A lower priority bug or feature requestA lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packageIssues with the analyzer's support for the linter packagelinter-lint-proposallinter-status-pendingtype-enhancementA request for a change that isn't a bugA request for a change that isn't a bug