Skip to content
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

Lint for unspecified type arguments when a type parameter has an upper bound. #57156

Closed
pq opened this issue Feb 5, 2015 · 1 comment
Closed
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-lint-request type-enhancement A request for a change that isn't a bug

Comments

@pq
Copy link
Member

pq commented Feb 5, 2015

Or more assertively:

DO: specify a type argument when a type parameter has an upper bound.

As a motivational example take the dart:math Point class:

class Point<T extends num>

The trouble is that this is legal:

Point p = new Point('hello', 'world');

and only fails at runtime if magnitude is called:

Unhandled exception:
type 'String' is not a subtype of type 'int' of 'times'.

To be sure Point is a special case but a general rule might be useful since in general if an upper bound has been defined dynamic is almost certainly not what's intended.

@srawlins
Copy link
Member

Since Dart 2 enforces argument types, I think this request is stale.

@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. linter-lint-request type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants