test_types_in_equals
Missing type test for '{0}' in '=='.
Description
#The analyzer produces this diagnostic when an override of the ==
operator doesn't include a type test on the value of the parameter.
Example
#The following code produces this diagnostic because other
is not type tested:
dart
class C {
final int f;
C(this.f);
@override
bool operator ==(Object other) {
return (other as C).f == f;
}
}
Common fixes
#Perform an is
test as part of computing the return value:
dart
class C {
final int f;
C(this.f);
@override
bool operator ==(Object other) {
return other is C && other.f == f;
}
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.