Do not mix expect/non-expect overloads of minOf/maxOf

Workaround for KT-22520
This commit is contained in:
Ilya Gorbunov
2018-01-25 19:05:36 +03:00
parent 912c69aaa3
commit f7b2eba680
4 changed files with 114 additions and 18 deletions
@@ -17,9 +17,7 @@ import kotlin.comparisons.*
* If values are equal, returns the first one.
*/
@SinceKotlin("1.1")
public fun <T: Comparable<T>> maxOf(a: T, b: T): T {
return if (a >= b) a else b
}
public expect fun <T: Comparable<T>> maxOf(a: T, b: T): T
/**
* Returns the greater of two values.
@@ -67,9 +65,7 @@ public expect inline fun maxOf(a: Double, b: Double): Double
* Returns the greater of three values.
*/
@SinceKotlin("1.1")
public fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T {
return maxOf(a, maxOf(b, c))
}
public expect fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T
/**
* Returns the greater of three values.
@@ -97,9 +93,7 @@ public expect inline fun maxOf(a: Int, b: Int, c: Int): Int
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public inline fun maxOf(a: Long, b: Long, c: Long): Long {
return maxOf(a, maxOf(b, c))
}
public expect inline fun maxOf(a: Long, b: Long, c: Long): Long
/**
* Returns the greater of three values.
@@ -137,9 +131,7 @@ public fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T {
* If values are equal, returns the first one.
*/
@SinceKotlin("1.1")
public fun <T: Comparable<T>> minOf(a: T, b: T): T {
return if (a <= b) a else b
}
public expect fun <T: Comparable<T>> minOf(a: T, b: T): T
/**
* Returns the smaller of two values.
@@ -187,9 +179,7 @@ public expect inline fun minOf(a: Double, b: Double): Double
* Returns the smaller of three values.
*/
@SinceKotlin("1.1")
public fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T {
return minOf(a, minOf(b, c))
}
public expect fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T
/**
* Returns the smaller of three values.
@@ -217,9 +207,7 @@ public expect inline fun minOf(a: Int, b: Int, c: Int): Int
*/
@SinceKotlin("1.1")
@kotlin.internal.InlineOnly
public inline fun minOf(a: Long, b: Long, c: Long): Long {
return minOf(a, minOf(b, c))
}
public expect inline fun minOf(a: Long, b: Long, c: Long): Long
/**
* Returns the smaller of three values.