Unverified Commit 2be0d57f authored by Ren You's avatar Ren You Committed by GitHub

Revert "Audit hashCode overrides outside of packages/flutter (#85370)" (#85451)

This reverts commit 9846fa51.
parent d5868732
...@@ -610,7 +610,7 @@ class Hash256 { ...@@ -610,7 +610,7 @@ class Hash256 {
} }
@override @override
int get hashCode => Object.hash(a, b, c, d); int get hashCode => a ^ b ^ c ^ d;
} }
// DO NOT ADD ANY ENTRIES TO THIS LIST. // DO NOT ADD ANY ENTRIES TO THIS LIST.
......
...@@ -28,7 +28,20 @@ class RunningProcessInfo { ...@@ -28,7 +28,20 @@ class RunningProcessInfo {
} }
@override @override
int get hashCode => Object.hash(pid, commandLine, creationDate); 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;
}
@override @override
String toString() { String toString() {
......
...@@ -166,14 +166,15 @@ class CommandArgs { ...@@ -166,14 +166,15 @@ class CommandArgs {
} }
@override @override
int get hashCode { int get hashCode => 17 * (17 * command.hashCode + _hashArguments) + _hashEnvironment;
return Object.hash(
command, int get _hashArguments => arguments != null
Object.hashAll(arguments ?? const <String>[]), ? const ListEquality<String>().hash(arguments)
Object.hashAllUnordered(environment?.keys ?? const <String>[]), : null.hashCode;
Object.hashAllUnordered(environment?.values ?? const <String>[]),
); int get _hashEnvironment => environment != null
} ? const MapEquality<String, String>().hash(environment)
: null.hashCode;
} }
class FakeDevice extends AndroidDevice { class FakeDevice extends AndroidDevice {
......
...@@ -183,7 +183,8 @@ class Rect { ...@@ -183,7 +183,8 @@ class Rect {
final double bottom; final double bottom;
@override @override
int get hashCode => Object.hash(top, left, right, bottom); int get hashCode =>
top.hashCode ^ left.hashCode ^ right.hashCode ^ bottom.hashCode;
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
...@@ -215,7 +216,7 @@ class Size { ...@@ -215,7 +216,7 @@ class Size {
final double height; final double height;
@override @override
int get hashCode => Object.hash(width, height); int get hashCode => width.hashCode ^ height.hashCode;
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
......
...@@ -128,7 +128,9 @@ class LocaleInfo implements Comparable<LocaleInfo> { ...@@ -128,7 +128,9 @@ class LocaleInfo implements Comparable<LocaleInfo> {
} }
@override @override
int get hashCode => originalString.hashCode; int get hashCode {
return originalString.hashCode;
}
@override @override
String toString() { String toString() {
......
...@@ -274,7 +274,7 @@ class FrameData { ...@@ -274,7 +274,7 @@ class FrameData {
} }
@override @override
int get hashCode => Object.hash(size, Object.hashAll(paths)); int get hashCode => size.hashCode ^ paths.hashCode;
@override @override
String toString() { String toString() {
...@@ -328,7 +328,7 @@ class SvgPath { ...@@ -328,7 +328,7 @@ class SvgPath {
} }
@override @override
int get hashCode => Object.hash(id, Object.hashAll(commands), opacity); int get hashCode => id.hashCode ^ commands.hashCode ^ opacity.hashCode;
@override @override
String toString() { String toString() {
...@@ -377,7 +377,7 @@ class SvgPathCommand { ...@@ -377,7 +377,7 @@ class SvgPathCommand {
} }
@override @override
int get hashCode => Object.hash(type, Object.hashAll(points)); int get hashCode => type.hashCode ^ points.hashCode;
@override @override
String toString() { String toString() {
......
...@@ -798,7 +798,7 @@ class _DetailArguments { ...@@ -798,7 +798,7 @@ class _DetailArguments {
} }
@override @override
int get hashCode => hashValues(packageName, hashList(licenseEntries)); int get hashCode => packageName.hashCode; // Good enough.
} }
class _PackageLicensePage extends StatefulWidget { class _PackageLicensePage extends StatefulWidget {
......
...@@ -814,5 +814,5 @@ class DriverOffset { ...@@ -814,5 +814,5 @@ class DriverOffset {
} }
@override @override
int get hashCode => Object.hash(dx, dy); int get hashCode => dx.hashCode ^ dy.hashCode;
} }
...@@ -911,7 +911,11 @@ class _Asset { ...@@ -911,7 +911,11 @@ class _Asset {
} }
@override @override
int get hashCode => Object.hash(baseDir, relativeUri, entryUri.hashCode); int get hashCode {
return baseDir.hashCode
^ relativeUri.hashCode
^ entryUri.hashCode;
}
} }
// Given an assets directory like this: // Given an assets directory like this:
......
...@@ -128,7 +128,10 @@ class Fingerprint { ...@@ -128,7 +128,10 @@ class Fingerprint {
} }
@override @override
int get hashCode => Object.hash(Object.hashAllUnordered(_checksums.keys), Object.hashAllUnordered(_checksums.values)); // Ignore map entries here to avoid becoming inconsistent with equals
// due to differences in map entry order. This is a really bad hash
// function and should eventually be deprecated and removed.
int get hashCode => _checksums.length.hashCode;
@override @override
String toString() => '{checksums: $_checksums}'; String toString() => '{checksums: $_checksums}';
......
...@@ -98,7 +98,7 @@ class Version implements Comparable<Version> { ...@@ -98,7 +98,7 @@ class Version implements Comparable<Version> {
} }
@override @override
int get hashCode => Object.hash(major, minor, patch); int get hashCode => major ^ minor ^ patch;
bool operator <(Version other) => compareTo(other) < 0; bool operator <(Version other) => compareTo(other) < 0;
bool operator >(Version other) => compareTo(other) > 0; bool operator >(Version other) => compareTo(other) > 0;
......
...@@ -278,7 +278,7 @@ class ValidationMessage { ...@@ -278,7 +278,7 @@ class ValidationMessage {
} }
@override @override
int get hashCode => Object.hash(type, message, contextUrl); int get hashCode => type.hashCode ^ message.hashCode ^ contextUrl.hashCode;
} }
class NoIdeValidator extends DoctorValidator { class NoIdeValidator extends DoctorValidator {
......
...@@ -302,7 +302,7 @@ class XcodeProjectBuildContext { ...@@ -302,7 +302,7 @@ class XcodeProjectBuildContext {
final EnvironmentType environmentType; final EnvironmentType environmentType;
@override @override
int get hashCode => Object.hash(scheme, configuration, environmentType); int get hashCode => scheme.hashCode ^ configuration.hashCode ^ environmentType.hashCode;
@override @override
bool operator ==(Object other) { bool operator ==(Object other) {
......
...@@ -129,7 +129,9 @@ class LocaleInfo implements Comparable<LocaleInfo> { ...@@ -129,7 +129,9 @@ class LocaleInfo implements Comparable<LocaleInfo> {
} }
@override @override
int get hashCode => originalString.hashCode; int get hashCode {
return originalString.hashCode;
}
@override @override
String toString() { String toString() {
......
...@@ -326,7 +326,12 @@ class CustomDimensions { ...@@ -326,7 +326,12 @@ class CustomDimensions {
} }
@override @override
int get hashCode => Object.hashAll(toMap().values); int get hashCode =>
toMap()
.values
.where((String element) => element != null)
.fold(Object().hashCode,
(int value, String element) => value ^ element.hashCode);
} }
/// List of all fields used in CustomDimensions. /// List of all fields used in CustomDimensions.
......
...@@ -486,7 +486,7 @@ class TestUsageCommand { ...@@ -486,7 +486,7 @@ class TestUsageCommand {
} }
@override @override
int get hashCode => Object.hash(command, parameters); int get hashCode => command.hashCode ^ parameters.hashCode;
@override @override
String toString() => 'TestUsageCommand($command, parameters:$parameters)'; String toString() => 'TestUsageCommand($command, parameters:$parameters)';
...@@ -514,7 +514,11 @@ class TestUsageEvent { ...@@ -514,7 +514,11 @@ class TestUsageEvent {
} }
@override @override
int get hashCode => Object.hash(category, parameter, label, value, parameters); int get hashCode => category.hashCode ^
parameter.hashCode ^
label.hashCode ^
value.hashCode ^
parameters.hashCode;
@override @override
String toString() => 'TestUsageEvent($category, $parameter, label:$label, value:$value, parameters:$parameters)'; String toString() => 'TestUsageEvent($category, $parameter, label:$label, value:$value, parameters:$parameters)';
...@@ -540,7 +544,10 @@ class TestTimingEvent { ...@@ -540,7 +544,10 @@ class TestTimingEvent {
} }
@override @override
int get hashCode => Object.hash(category, variableName, duration, label); int get hashCode => category.hashCode ^
variableName.hashCode ^
duration.hashCode ^
label.hashCode;
@override @override
String toString() => 'TestTimingEvent($category, $variableName, $duration, label:$label)'; String toString() => 'TestTimingEvent($category, $variableName, $duration, label:$label)';
......
...@@ -326,5 +326,5 @@ class VsCodeInstallLocation { ...@@ -326,5 +326,5 @@ class VsCodeInstallLocation {
@override @override
// Lowest bit is for isInsiders boolean. // Lowest bit is for isInsiders boolean.
int get hashCode => Object.hash(installPath, extensionsFolder, edition); int get hashCode => installPath.hashCode ^ extensionsFolder.hashCode ^ edition.hashCode;
} }
...@@ -219,7 +219,7 @@ class CleanWorkspaceCall { ...@@ -219,7 +219,7 @@ class CleanWorkspaceCall {
verbose == other.verbose; verbose == other.verbose;
@override @override
int get hashCode => Object.hash(workspacePath, scheme, verbose); int get hashCode => workspacePath.hashCode;
@override @override
String toString() => '{$workspacePath, $scheme, $verbose}'; String toString() => '{$workspacePath, $scheme, $verbose}';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment