Revert "Revert "Audit hashCode overrides outside of packages/flutter (#85370)" (#85451)" (#85567)
This reverts commit 2be0d57fa25423ffcba5a07d22ef9386a89dcf4c.
diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart
index 35865ea..dc98d75 100644
--- a/dev/bots/analyze.dart
+++ b/dev/bots/analyze.dart
@@ -610,7 +610,7 @@
}
@override
- int get hashCode => a ^ b ^ c ^ d;
+ int get hashCode => Object.hash(a, b, c, d);
}
// DO NOT ADD ANY ENTRIES TO THIS LIST.
diff --git a/dev/devicelab/lib/framework/running_processes.dart b/dev/devicelab/lib/framework/running_processes.dart
index a96254f..b07f1c1 100644
--- a/dev/devicelab/lib/framework/running_processes.dart
+++ b/dev/devicelab/lib/framework/running_processes.dart
@@ -28,20 +28,7 @@
}
@override
- int get hashCode {
- // TODO(dnfield): Replace this when Object.hashValues lands, https://github.com/dart-lang/sdk/issues/11617
- int hash = 17;
- if (pid != null) {
- hash = hash * 23 + pid.hashCode;
- }
- if (commandLine != null) {
- hash = hash * 23 + commandLine.hashCode;
- }
- if (creationDate != null) {
- hash = hash * 23 + creationDate.hashCode;
- }
- return hash;
- }
+ int get hashCode => Object.hash(pid, commandLine, creationDate);
@override
String toString() {
diff --git a/dev/devicelab/test/adb_test.dart b/dev/devicelab/test/adb_test.dart
index 018ce40..bd9cb6a 100644
--- a/dev/devicelab/test/adb_test.dart
+++ b/dev/devicelab/test/adb_test.dart
@@ -166,15 +166,14 @@
}
@override
- int get hashCode => 17 * (17 * command.hashCode + _hashArguments) + _hashEnvironment;
-
- int get _hashArguments => arguments != null
- ? const ListEquality<String>().hash(arguments)
- : null.hashCode;
-
- int get _hashEnvironment => environment != null
- ? const MapEquality<String, String>().hash(environment)
- : null.hashCode;
+ int get hashCode {
+ return Object.hash(
+ command,
+ Object.hashAll(arguments ?? const <String>[]),
+ Object.hashAllUnordered(environment?.keys ?? const <String>[]),
+ Object.hashAllUnordered(environment?.values ?? const <String>[]),
+ );
+ }
}
class FakeDevice extends AndroidDevice {
diff --git a/dev/integration_tests/android_semantics_testing/lib/src/common.dart b/dev/integration_tests/android_semantics_testing/lib/src/common.dart
index 8879850..b01c2fc 100644
--- a/dev/integration_tests/android_semantics_testing/lib/src/common.dart
+++ b/dev/integration_tests/android_semantics_testing/lib/src/common.dart
@@ -183,8 +183,7 @@
final double bottom;
@override
- int get hashCode =>
- top.hashCode ^ left.hashCode ^ right.hashCode ^ bottom.hashCode;
+ int get hashCode => Object.hash(top, left, right, bottom);
@override
bool operator ==(Object other) {
@@ -216,7 +215,7 @@
final double height;
@override
- int get hashCode => width.hashCode ^ height.hashCode;
+ int get hashCode => Object.hash(width, height);
@override
bool operator ==(Object other) {
diff --git a/dev/tools/localization/localizations_utils.dart b/dev/tools/localization/localizations_utils.dart
index 1209749..e3373dc 100644
--- a/dev/tools/localization/localizations_utils.dart
+++ b/dev/tools/localization/localizations_utils.dart
@@ -128,9 +128,7 @@
}
@override
- int get hashCode {
- return originalString.hashCode;
- }
+ int get hashCode => originalString.hashCode;
@override
String toString() {
diff --git a/dev/tools/vitool/lib/vitool.dart b/dev/tools/vitool/lib/vitool.dart
index 0f0f4bc..e60bb71 100644
--- a/dev/tools/vitool/lib/vitool.dart
+++ b/dev/tools/vitool/lib/vitool.dart
@@ -274,7 +274,7 @@
}
@override
- int get hashCode => size.hashCode ^ paths.hashCode;
+ int get hashCode => Object.hash(size, Object.hashAll(paths));
@override
String toString() {
@@ -328,7 +328,7 @@
}
@override
- int get hashCode => id.hashCode ^ commands.hashCode ^ opacity.hashCode;
+ int get hashCode => Object.hash(id, Object.hashAll(commands), opacity);
@override
String toString() {
@@ -377,7 +377,7 @@
}
@override
- int get hashCode => type.hashCode ^ points.hashCode;
+ int get hashCode => Object.hash(type, Object.hashAll(points));
@override
String toString() {