-
Notifications
You must be signed in to change notification settings - Fork 322
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
Make operator == override parameters non-nullable #677
Conversation
I'd love to see those CI failure details. |
runtimeType == other.runtimeType && | ||
characteristicId == other.characteristicId && | ||
serviceId == other.serviceId; | ||
characteristicId == (other as DiscoveredCharacteristic).characteristicId && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is some technical debt here, as this cast could fail at runtime. But I am only here to make a no-op change, and not change behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@srawlins I came to the same conclusion here.
What if you did
@override
bool operator ==(Object other) {
return other is DiscoveredCharacteristic &&
runtimeType == other.runtimeType &&
characteristicId == other. characteristicId &&
serviceId == other. serviceId;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely the change I would want to make at some point if I owned the code.
This would be a behavior-changing change, which I am not very comfortable making. x.runtime == y.runtime
is different from x == Y
. I don't know what subtypes there are, or where exception catching happens and if specific exceptions are caught here or there. I don't want to land a change that is then rolled back because of the changes unrelated to correcting the static analysis issue.
All that being said, I can make your suggested change if you would really like me to.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then again, now that I can see the static analysis issues, it looks like I must make the suggested change, to avoid test_types_in_equals
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -31,9 +31,9 @@ class QualifiedCharacteristic { | |||
deviceId.hashCode; | |||
|
|||
@override | |||
bool operator ==(dynamic other) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here:
@override
bool operator ==(Object other) {
return other is QualifiedCharacteristic &&
runtimeType == other.runtimeType &&
characteristicId == other. characteristicId &&
serviceId == other. serviceId && deviceId == other. deviceId;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -68,9 +68,9 @@ class Uuid { | |||
data.fold(17, (hash, octet) => 37 * hash + octet.hashCode); | |||
|
|||
@override | |||
bool operator ==(dynamic other) => | |||
bool operator ==(Object other) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing here:
@override
bool operator ==(Object other) {
return other is Uuid && other.runtimeType == runtimeType &&
const DeepCollectionEquality().equals(other.data, data);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
You dont need CI, you can check it locally with melos |
Ready for review |
return other is Uuid && | ||
other.runtimeType == runtimeType && | ||
const DeepCollectionEquality().equals(other.data, data); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still failing, please check quality locally:
$ melos exec
└> flutter analyze
└> FAILED (in 1 packages)
└> reactive_ble_platform_interface (with exit code 1)
melos run analyze
└> melos exec -- flutter analyze
└> FAILED
ScriptException: The script analyze failed to execute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, complete.
Ready for review |
1 similar comment
Ready for review |
Thank you! |
* Make operator == override parameters no-nullable. See dart-lang/linter#3441 Work towards dart-lang/sdk#51038.
Make operator == override parameters non-nullable. See dart-lang/linter#3441
Work towards dart-lang/sdk#51038.