Skip to content

new lint: flag "raw" generic method/tear-off invocations (a la always_specify_types) #58501

Open
@pq

Description

@pq

Specifically, we do not currently lint the following "raw" invocation but maybe we should?

List<T> makeList<T>() => <T>[];

void f() {
  makeList<int>(); // OK
  makeList(); // <== LINT?
}

By extension, this would likely carry over to similar advice for constructor tear-offs. (See: #58424.)

List<E> Function<E>(int, E) filledList = List.filled; // OK
filledList<int>(3, 3); // OK
filledList(3, 3); // LINT?

@davidmorgan: I believe this rule is banned internally but I wonder if you have an opinions?

@goderbauer: similarly, you all don't use this rule but wonder if you have thoughts?

/cc @bwilkerson


EDIT this issue started as a reflection on updating always_specify_types to catch invocations. After some feedback and consideration, the better approach seems to be a new lint.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter packagelinter-false-negativelinter-new-language-featuretype-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