Chromium Code Reviews| Index: lib/src/version.dart |
| diff --git a/lib/src/version.dart b/lib/src/version.dart |
| index 98722897cb39e2dd3dde17b6b1c54fda13e47fbd..f2662b9aaada76cec70f5f63ccc9cebfa0c7dcaa 100644 |
| --- a/lib/src/version.dart |
| +++ b/lib/src/version.dart |
| @@ -14,7 +14,7 @@ import 'version_range.dart'; |
| final _equality = const IterableEquality(); |
| /// A parsed semantic version number. |
| -class Version implements Comparable<Version>, VersionConstraint, VersionRange { |
| +class Version implements VersionConstraint, VersionRange { |
|
Bob Nystrom
2016/06/03 16:18:03
Can this implement Comparable<VersionRange>?
nweiz
2016/06/06 22:27:46
It already does, transitively through VersionRange
|
| /// No released version: i.e. "0.0.0". |
| static Version get none => new Version(0, 0, 0); |
| @@ -267,22 +267,26 @@ class Version implements Comparable<Version>, VersionConstraint, VersionRange { |
| return new VersionConstraint.unionOf([this, other]); |
| } |
| - int compareTo(Version other) { |
| - if (major != other.major) return major.compareTo(other.major); |
| - if (minor != other.minor) return minor.compareTo(other.minor); |
| - if (patch != other.patch) return patch.compareTo(other.patch); |
| - |
| - // Pre-releases always come before no pre-release string. |
| - if (!isPreRelease && other.isPreRelease) return 1; |
| - if (!other.isPreRelease && isPreRelease) return -1; |
| - |
| - var comparison = _compareLists(preRelease, other.preRelease); |
| - if (comparison != 0) return comparison; |
| - |
| - // Builds always come after no build string. |
| - if (build.isEmpty && other.build.isNotEmpty) return -1; |
| - if (other.build.isEmpty && build.isNotEmpty) return 1; |
| - return _compareLists(build, other.build); |
| + int compareTo(VersionRange other) { |
| + if (other is Version) { |
|
Bob Nystrom
2016/06/03 16:18:03
Might be a bit simpler to do the negative test:
i
nweiz
2016/06/06 22:27:46
https://github.com/dart-lang/sdk/issues/25565 :(
|
| + if (major != other.major) return major.compareTo(other.major); |
| + if (minor != other.minor) return minor.compareTo(other.minor); |
| + if (patch != other.patch) return patch.compareTo(other.patch); |
| + |
| + // Pre-releases always come before no pre-release string. |
| + if (!isPreRelease && other.isPreRelease) return 1; |
| + if (!other.isPreRelease && isPreRelease) return -1; |
| + |
| + var comparison = _compareLists(preRelease, other.preRelease); |
| + if (comparison != 0) return comparison; |
| + |
| + // Builds always come after no build string. |
| + if (build.isEmpty && other.build.isNotEmpty) return -1; |
| + if (other.build.isEmpty && build.isNotEmpty) return 1; |
| + return _compareLists(build, other.build); |
| + } else { |
| + return -other.compareTo(this); |
| + } |
| } |
| String toString() => _text; |