Skip to content

Lint that flags uses of Map, Set, or List with keys outside the domain of the type #58604

Closed
@Hixie

Description

@Hixie

According to #48030, it's intentional that you can do things like:

  Map<String, int> foo = {};
  // ...
  print(foo[2]); // prints null, since foo cannot possibly contain an entry with key 2

It would be nice if that tripped a lint to warn you that you're doing something almost certainly invalid.

This would apply to all the methods and operators on the container classes that are defined to take Object? instead of K.

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions