Closed
Description
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
.