Cleanup equality operator to accept any Object rather than just a SourceLocation.
BUG=
R=nweiz@google.com
Review URL: https://codereview.chromium.org//881673002
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f057e9b..195bcf8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 1.0.3
+
+* Cleanup equality operator to accept any Object rather than just a
+ `SourceLocation`.
+
# 1.0.2
* Avoid unintentionally allocating extra objects for internal `FileSpan`
diff --git a/lib/src/location.dart b/lib/src/location.dart
index 41f2518..2705742 100644
--- a/lib/src/location.dart
+++ b/lib/src/location.dart
@@ -77,8 +77,9 @@
return offset - other.offset;
}
- bool operator ==(SourceLocation other) =>
- sourceUrl == other.sourceUrl && offset == other.offset;
+ bool operator ==(other) =>
+ other is SourceLocation && sourceUrl == other.sourceUrl &&
+ offset == other.offset;
int get hashCode => sourceUrl.hashCode + offset;
diff --git a/pubspec.yaml b/pubspec.yaml
index 55ac89a..03b290b 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: source_span
-version: 1.0.2
+version: 1.0.3
author: Dart Team <misc@dartlang.org>
description: A library for identifying source spans and locations.
homepage: http://github.com/dart-lang/source_span