Skip to content

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

@pq

Description

@pq

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions