Skip to content

prefer_contains does not catch type parameters bound to Iterable (or promoted to) #58406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
srawlins opened this issue May 20, 2021 · 0 comments
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. linter-false-negative linter-set-recommended P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@srawlins
Copy link
Member

Describe the issue

prefer_contains does not catch type parameters bound to Iterable (or promoted to a bound of Iterable). For example:

To Reproduce

bool typeVariableBoundToList<T extends List<int>>(T list) =>
    list.indexOf(1) < 0; // LINT

bool typeVariablePromotedToList<T>(T list) =>
    list is List<int> && list.indexOf(1) < 0; // LINT

Expected behavior

Each of these should be reported.

Additional context

The recent typeForInterfaceCheck extension method on DartType should help. only_throw_errors needed a similar fix.

@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label May 21, 2021
@pq pq added the P2 A bug or feature request we're likely to work on label Nov 14, 2022
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 19, 2024
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. linter-false-negative linter-set-recommended P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants