Skip to content

test_types_in_equals false positive #35523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Hixie opened this issue Dec 30, 2018 · 2 comments
Closed

test_types_in_equals false positive #35523

Hixie opened this issue Dec 30, 2018 · 2 comments
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Hixie
Copy link
Contributor

Hixie commented Dec 30, 2018

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)

...which is wrong. The type is checked, in the first line. The advice on the Web page (http://dart-lang.github.io/linter/lints/test_types_in_equals.html) is actually bad, because it does a check using "is" which doesn't guarantee equality, and leads to asymmetric equality, where a == b but b != a if a is an instance of a superclass of b.

@Hixie
Copy link
Contributor Author

Hixie commented Dec 30, 2018

See also #35522 which is about the lint's wording being unclear. This specific issue is about the heuristics of the lint being bad.

@lrhn lrhn added the legacy-area-analyzer Use area-devexp instead. label Jan 3, 2019
@stereotype441 stereotype441 added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Jan 3, 2019
@stereotype441 stereotype441 added the devexp-linter Issues with the analyzer's support for the linter package label Jan 28, 2019
@pq
Copy link
Member

pq commented Jan 28, 2019

This issue was moved to #57891

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants