-
Notifications
You must be signed in to change notification settings - Fork 21
Remove avoid_null_checks_in_equality_operators
from recommended
#829
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
cc @natebosch, @goderbauer, and @lrhn for thoughts |
Are there exceptions to the NON_NULLABLE_EQUALS_PARAMETER warning. For example of the parameter type is neither nullable nor non-nullable? class C<T extends C<T>?> {
bool operator ==(covariant T o) => ...
} where extension type Maybe(Object? o) {
bool check(C me) { ... }
}
class C {
bool operator ==(covariant Maybe other) => other.check(me);
} where you won't get a warning, and you can't really provide a non-potentially nullable type with the same effect. Probably fine. |
Removing SGTM. |
resolution: sgtm to remove |
I get "invalid override" for this example, and for the extension type example; it seems even with the "covariant" keyword, these are illegal? But no "NON_NULLABLE_EQUALS_PARAMETER" warning. Given this code: class C<T extends C<T>?> {
bool operator ==(covariant T o) => false;
}
class D {
bool operator ==(covariant int? o) => false;
}
void main() {} both CFE and analyzer report that |
closed by dart-archive/lints#201 |
We introduced a new Warning called
NON_NULLABLE_EQUALS_PARAMETER
a few releases ago. It warns when the parameter of anoperator ==
override has a nullable type:I didn't realize it at the time, but that new warning, plus null safety, basically replace the
avoid_null_checks_in_equality_operators
lint rule. This rule reports doing any null-check work on a nullable parameter of anoperator ==
override.As I found out when I migrated the tests from the legacy framework, the rule is a bit non-sensical now because of the redundancy. Every test case either has a
WarningCode.NON_NULLABLE_EQUALS_PARAMETER
, if it features a nullable parameter, or it features another warning likeWarningCode.UNNECESSARY_NULL_COMPARISON_TRUE
orStaticWarningCode.INVALID_NULL_AWARE_OPERATOR
, if the parameter is non-nullable and is compared tonull
.The text was updated successfully, but these errors were encountered: