Index: lib/src/file.dart |
diff --git a/lib/src/file.dart b/lib/src/file.dart |
index c180929f785e8698689c907c221b4013204d7ead..efd0da881b38bf076bae4254d42d4ce83de8c0f7 100644 |
--- a/lib/src/file.dart |
+++ b/lib/src/file.dart |
@@ -242,12 +242,17 @@ class _FileSpan extends SourceSpanMixin implements FileSpan { |
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; |