Make the package strong-mode clean. This caught a bug in which we were calling _FileSpan._start and _FileSpan._end on a span we couldn't guarantee to be a _FileSpan. R=sigmund@google.com Review URL: https://codereview.chromium.org//1328583002 .
diff --git a/pkgs/source_span/CHANGELOG.md b/pkgs/source_span/CHANGELOG.md index 5f87aee..10d94f6 100644 --- a/pkgs/source_span/CHANGELOG.md +++ b/pkgs/source_span/CHANGELOG.md
@@ -1,3 +1,8 @@ +# 1.1.5 + +* Fixed another case in which `FileSpan.union` could throw an exception for + external implementations of `FileSpan`. + # 1.1.4 * Eliminated dart2js warning about overriding `==`, but not `hashCode`.
diff --git a/pkgs/source_span/lib/src/file.dart b/pkgs/source_span/lib/src/file.dart index aee3d78..e5bc53c 100644 --- a/pkgs/source_span/lib/src/file.dart +++ b/pkgs/source_span/lib/src/file.dart
@@ -242,12 +242,17 @@ SourceSpan union(SourceSpan other) { if (other is! FileSpan) return super.union(other); + _FileSpan span = expand(other); - var beginSpan = span._start == _start ? this : other; - var endSpan = span._end == _end ? this : other; - if (beginSpan._end < endSpan._start) { - throw new ArgumentError("Spans $this and $other are disjoint."); + if (other is _FileSpan) { + if (this._start > other._end || other._start > this._end) { + throw new ArgumentError("Spans $this and $other are disjoint."); + } + } else { + if (this._start > other.end.offset || other.start.offset > this._end) { + throw new ArgumentError("Spans $this and $other are disjoint."); + } } return span;
diff --git a/pkgs/source_span/pubspec.yaml b/pkgs/source_span/pubspec.yaml index 3da9c28..2bfbe4e 100644 --- a/pkgs/source_span/pubspec.yaml +++ b/pkgs/source_span/pubspec.yaml
@@ -1,5 +1,5 @@ name: source_span -version: 1.1.4 +version: 1.1.5 author: Dart Team <misc@dartlang.org> description: A library for identifying source spans and locations. homepage: https://github.com/dart-lang/source_span