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/pkgs/source_span/CHANGELOG.md b/pkgs/source_span/CHANGELOG.md index f057e9b..195bcf8 100644 --- a/pkgs/source_span/CHANGELOG.md +++ b/pkgs/source_span/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/pkgs/source_span/lib/src/location.dart b/pkgs/source_span/lib/src/location.dart index 41f2518..2705742 100644 --- a/pkgs/source_span/lib/src/location.dart +++ b/pkgs/source_span/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/pkgs/source_span/pubspec.yaml b/pkgs/source_span/pubspec.yaml index 55ac89a..03b290b 100644 --- a/pkgs/source_span/pubspec.yaml +++ b/pkgs/source_span/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