[Gradle, JS] Min and max are not nullable
^KT-41054 fixed
This commit is contained in:
+8
-2
@@ -31,9 +31,15 @@ val NONE_RANGE = NpmRange(
|
||||
infix fun NpmRange.union(other: NpmRange): List<NpmRange> {
|
||||
if (!isIntersect(other)) return listOf(this, other)
|
||||
|
||||
val startVersion = min(this.startVersion, other.startVersion)
|
||||
val startVersion = when {
|
||||
this.startVersion == null || other.startVersion == null -> null
|
||||
else -> min(this.startVersion, other.startVersion)
|
||||
}
|
||||
|
||||
val endVersion = max(this.endVersion, other.endVersion)
|
||||
val endVersion = when {
|
||||
this.endVersion == null || other.endVersion == null -> null
|
||||
else -> max(this.endVersion, other.endVersion)
|
||||
}
|
||||
|
||||
return NpmRange(
|
||||
startVersion = startVersion,
|
||||
|
||||
+4
-10
@@ -182,14 +182,8 @@ fun Version.toSemVer(): SemVer =
|
||||
build = buildIdentifiers.joinToString(".").let { if (it.isNotEmpty()) it else null }
|
||||
)
|
||||
|
||||
fun min(a: SemVer?, b: SemVer?): SemVer? {
|
||||
if (a == null || b == null) return null
|
||||
fun min(a: SemVer, b: SemVer): SemVer =
|
||||
if (a < b) a else b
|
||||
|
||||
return if (a < b) a else b
|
||||
}
|
||||
|
||||
fun max(a: SemVer?, b: SemVer?): SemVer? {
|
||||
if (a == null || b == null) return null
|
||||
|
||||
return if (a > b) a else b
|
||||
}
|
||||
fun max(a: SemVer, b: SemVer): SemVer =
|
||||
if (a > b) a else b
|
||||
Reference in New Issue
Block a user