[Gradle, JS] Min and max are not nullable

^KT-41054 fixed
This commit is contained in:
Ilya Goncharov
2020-08-05 14:48:52 +03:00
parent 966c9dae68
commit fec8c6c0ae
2 changed files with 12 additions and 12 deletions
@@ -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,
@@ -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