Skip to content

test_types_in_equals false positive with runtimeType #57891

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

Open
pq opened this issue Jan 28, 2019 · 1 comment
Open

test_types_in_equals false positive with runtimeType #57891

pq opened this issue Jan 28, 2019 · 1 comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-false-positive 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

@pq
Copy link
Member

pq commented Jan 28, 2019

From @Hixie on December 30, 2018 19:30

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.

Copied from original issue: #35523

@pq pq added the P2 A bug or feature request we're likely to work on label Jan 28, 2019
@pq
Copy link
Member Author

pq commented Jan 28, 2019

From @Hixie on December 30, 2018 19:31

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

@srawlins srawlins added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Sep 12, 2019
@srawlins srawlins changed the title test_types_in_equals false positive test_types_in_equals false positive with runtimeType Nov 12, 2022
@devoncarew devoncarew added devexp-linter Issues with the analyzer's support for the linter package legacy-area-analyzer Use area-devexp instead. labels Nov 18, 2024
@devoncarew devoncarew transferred this issue from dart-archive/linter Nov 18, 2024
@bwilkerson bwilkerson added area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. and removed legacy-area-analyzer Use area-devexp instead. labels Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-devexp For issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages. devexp-linter Issues with the analyzer's support for the linter package linter-false-positive 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