Skip to content

Commit

Permalink
Cleanup equality operator to accept any Object rather than just a Sou…
Browse files Browse the repository at this point in the history
…rceLocation.

BUG=
R=nweiz@google.com

Review URL: https://codereview.chromium.org//881673002
  • Loading branch information
jacob314 committed Jan 27, 2015
1 parent 4250113 commit 691bc67
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
5 changes: 3 additions & 2 deletions lib/src/location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class SourceLocation implements Comparable<SourceLocation> {
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;

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 691bc67

Please sign in to comment.