dart-lang / linter

Linter for Dart.
https://dart.dev/tools/linter-rules
BSD 3-Clause "New" or "Revised" License
629 stars 170 forks source link

"Test type arguments in operator ==(Object other)" is a very confusing error message #1398

Open pq opened 5 years ago

pq commented 5 years ago

From @Hixie on December 30, 2018 19:28

This code:

  @override
  bool operator ==(dynamic other) {
    if (other.runtimeType != runtimeType)
      return false;
    final AvatarImage typedOther = other as AvatarImage; // line 465
    return username == typedOther.username
        && photoManager == typedOther.photoManager
        && twitarr == typedOther.twitarr;
  }

Led to this message from the analyzer:

[info] Test type arguments in operator ==(Object other) (/home/ianh/dev/cruisemonkey/lib/src/logic/cruise.dart:465:36)

I have no idea what this means.

Copied from original issue: dart-lang/sdk#35522

pq commented 5 years ago

From @Hixie on December 30, 2018 19:28

(See http://dart-lang.github.io/linter/lints/test_types_in_equals.html for what it actually means.)

pq commented 5 years ago

From @Hixie on December 30, 2018 19:30

See also https://github.com/dart-lang/sdk/issues/35523 which is about the lint itself being bad. This specific issue is about the wording of the lint being unclear.