Skip to content

Lint request: type parameter types shadowing interface types #58102

Closed
@MichaelRFairhurst

Description

@MichaelRFairhurst

Similar to https://dart-lang.github.io/linter/lints/avoid_types_as_parameter_names.html

But instead to catch:

@override
String doStuff<String>(String x) { ... }

Users do this thinking they are getting template specialization. However, that's not what occurs. But they get no error, and then the resulting errors later on will look like "String is not a String. Try casting to a String."

This is assuming a base class defines

T doStuff<T>(T x) { ... }

Also occurs like this:

class A<T> {
  ...
}

class B<String> extends A<String> {
  ...
}

I know I've done that before on accident.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions