Do not mix expect/non-expect overloads of minOf/maxOf
Workaround for KT-22520
This commit is contained in:
@@ -17,9 +17,7 @@ import kotlin.comparisons.*
|
|||||||
* If values are equal, returns the first one.
|
* If values are equal, returns the first one.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.1")
|
@SinceKotlin("1.1")
|
||||||
public fun <T: Comparable<T>> maxOf(a: T, b: T): T {
|
public expect fun <T: Comparable<T>> maxOf(a: T, b: T): T
|
||||||
return if (a >= b) a else b
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of two values.
|
* 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.
|
* Returns the greater of three values.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.1")
|
@SinceKotlin("1.1")
|
||||||
public fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T {
|
public expect fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T
|
||||||
return maxOf(a, maxOf(b, c))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of three values.
|
* 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")
|
@SinceKotlin("1.1")
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun maxOf(a: Long, b: Long, c: Long): Long {
|
public expect inline fun maxOf(a: Long, b: Long, c: Long): Long
|
||||||
return maxOf(a, maxOf(b, c))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of three values.
|
* 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.
|
* If values are equal, returns the first one.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.1")
|
@SinceKotlin("1.1")
|
||||||
public fun <T: Comparable<T>> minOf(a: T, b: T): T {
|
public expect fun <T: Comparable<T>> minOf(a: T, b: T): T
|
||||||
return if (a <= b) a else b
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of two values.
|
* 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.
|
* Returns the smaller of three values.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.1")
|
@SinceKotlin("1.1")
|
||||||
public fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T {
|
public expect fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T
|
||||||
return minOf(a, minOf(b, c))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of three values.
|
* 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")
|
@SinceKotlin("1.1")
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun minOf(a: Long, b: Long, c: Long): Long {
|
public expect inline fun minOf(a: Long, b: Long, c: Long): Long
|
||||||
return minOf(a, minOf(b, c))
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of three values.
|
* Returns the smaller of three values.
|
||||||
|
|||||||
@@ -13,6 +13,15 @@ import kotlin.*
|
|||||||
import kotlin.text.*
|
import kotlin.text.*
|
||||||
import kotlin.comparisons.*
|
import kotlin.comparisons.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the greater of two values.
|
||||||
|
* If values are equal, returns the first one.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
public actual fun <T: Comparable<T>> maxOf(a: T, b: T): T {
|
||||||
|
return if (a >= b) a else b
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of two values.
|
* Returns the greater of two values.
|
||||||
*/
|
*/
|
||||||
@@ -67,6 +76,14 @@ public actual inline fun maxOf(a: Double, b: Double): Double {
|
|||||||
return Math.max(a, b)
|
return Math.max(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the greater of three values.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
public actual fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T {
|
||||||
|
return maxOf(a, maxOf(b, c))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of three values.
|
* Returns the greater of three values.
|
||||||
*/
|
*/
|
||||||
@@ -94,6 +111,15 @@ public actual inline fun maxOf(a: Int, b: Int, c: Int): Int {
|
|||||||
return Math.max(a, b, c)
|
return Math.max(a, b, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the greater of three values.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public actual inline fun maxOf(a: Long, b: Long, c: Long): Long {
|
||||||
|
return maxOf(a, maxOf(b, c))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of three values.
|
* Returns the greater of three values.
|
||||||
*/
|
*/
|
||||||
@@ -112,6 +138,15 @@ public actual inline fun maxOf(a: Double, b: Double, c: Double): Double {
|
|||||||
return Math.max(a, b, c)
|
return Math.max(a, b, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the smaller of two values.
|
||||||
|
* If values are equal, returns the first one.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
public actual fun <T: Comparable<T>> minOf(a: T, b: T): T {
|
||||||
|
return if (a <= b) a else b
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of two values.
|
* Returns the smaller of two values.
|
||||||
*/
|
*/
|
||||||
@@ -166,6 +201,14 @@ public actual inline fun minOf(a: Double, b: Double): Double {
|
|||||||
return Math.min(a, b)
|
return Math.min(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the smaller of three values.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
public actual fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T {
|
||||||
|
return minOf(a, minOf(b, c))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of three values.
|
* Returns the smaller of three values.
|
||||||
*/
|
*/
|
||||||
@@ -193,6 +236,15 @@ public actual inline fun minOf(a: Int, b: Int, c: Int): Int {
|
|||||||
return Math.min(a, b, c)
|
return Math.min(a, b, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the smaller of three values.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public actual inline fun minOf(a: Long, b: Long, c: Long): Long {
|
||||||
|
return minOf(a, minOf(b, c))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of three values.
|
* Returns the smaller of three values.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -13,6 +13,15 @@ import kotlin.*
|
|||||||
import kotlin.text.*
|
import kotlin.text.*
|
||||||
import kotlin.comparisons.*
|
import kotlin.comparisons.*
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the greater of two values.
|
||||||
|
* If values are equal, returns the first one.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
public actual fun <T: Comparable<T>> maxOf(a: T, b: T): T {
|
||||||
|
return if (a >= b) a else b
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of two values.
|
* Returns the greater of two values.
|
||||||
*/
|
*/
|
||||||
@@ -67,6 +76,14 @@ public actual inline fun maxOf(a: Double, b: Double): Double {
|
|||||||
return Math.max(a, b)
|
return Math.max(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the greater of three values.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
public actual fun <T: Comparable<T>> maxOf(a: T, b: T, c: T): T {
|
||||||
|
return maxOf(a, maxOf(b, c))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of three values.
|
* Returns the greater of three values.
|
||||||
*/
|
*/
|
||||||
@@ -94,6 +111,15 @@ public actual inline fun maxOf(a: Int, b: Int, c: Int): Int {
|
|||||||
return maxOf(a, maxOf(b, c))
|
return maxOf(a, maxOf(b, c))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the greater of three values.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public actual inline fun maxOf(a: Long, b: Long, c: Long): Long {
|
||||||
|
return maxOf(a, maxOf(b, c))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the greater of three values.
|
* Returns the greater of three values.
|
||||||
*/
|
*/
|
||||||
@@ -112,6 +138,15 @@ public actual inline fun maxOf(a: Double, b: Double, c: Double): Double {
|
|||||||
return maxOf(a, maxOf(b, c))
|
return maxOf(a, maxOf(b, c))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the smaller of two values.
|
||||||
|
* If values are equal, returns the first one.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
public actual fun <T: Comparable<T>> minOf(a: T, b: T): T {
|
||||||
|
return if (a <= b) a else b
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of two values.
|
* Returns the smaller of two values.
|
||||||
*/
|
*/
|
||||||
@@ -166,6 +201,14 @@ public actual inline fun minOf(a: Double, b: Double): Double {
|
|||||||
return Math.min(a, b)
|
return Math.min(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the smaller of three values.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
public actual fun <T: Comparable<T>> minOf(a: T, b: T, c: T): T {
|
||||||
|
return minOf(a, minOf(b, c))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of three values.
|
* Returns the smaller of three values.
|
||||||
*/
|
*/
|
||||||
@@ -193,6 +236,15 @@ public actual inline fun minOf(a: Int, b: Int, c: Int): Int {
|
|||||||
return minOf(a, minOf(b, c))
|
return minOf(a, minOf(b, c))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the smaller of three values.
|
||||||
|
*/
|
||||||
|
@SinceKotlin("1.1")
|
||||||
|
@kotlin.internal.InlineOnly
|
||||||
|
public actual inline fun minOf(a: Long, b: Long, c: Long): Long {
|
||||||
|
return minOf(a, minOf(b, c))
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the smaller of three values.
|
* Returns the smaller of three values.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -179,6 +179,7 @@ object ComparableOps : TemplateGroupBase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
on(Platform.JS) { /* just to make expect, KT-22520 */ }
|
||||||
body(Generic) {
|
body(Generic) {
|
||||||
"return if (a <= b) a else b"
|
"return if (a <= b) a else b"
|
||||||
}
|
}
|
||||||
@@ -203,6 +204,7 @@ object ComparableOps : TemplateGroupBase() {
|
|||||||
body {
|
body {
|
||||||
"return minOf(a, minOf(b, c))"
|
"return minOf(a, minOf(b, c))"
|
||||||
}
|
}
|
||||||
|
on(Platform.JS) { /* just to make expect, KT-22520 */ }
|
||||||
specialFor(Primitives) {
|
specialFor(Primitives) {
|
||||||
if (primitive in shortIntPrimitives) {
|
if (primitive in shortIntPrimitives) {
|
||||||
body { "return Math.min(a.toInt(), Math.min(b.toInt(), c.toInt())).to$primitive()" }
|
body { "return Math.min(a.toInt(), Math.min(b.toInt(), c.toInt())).to$primitive()" }
|
||||||
@@ -291,6 +293,7 @@ object ComparableOps : TemplateGroupBase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
on(Platform.JS) { /* just to make expect, KT-22520 */ }
|
||||||
body(Generic) {
|
body(Generic) {
|
||||||
"return if (a >= b) a else b"
|
"return if (a >= b) a else b"
|
||||||
}
|
}
|
||||||
@@ -315,6 +318,7 @@ object ComparableOps : TemplateGroupBase() {
|
|||||||
body {
|
body {
|
||||||
"return maxOf(a, maxOf(b, c))"
|
"return maxOf(a, maxOf(b, c))"
|
||||||
}
|
}
|
||||||
|
on(Platform.JS) { /* just to make expect, KT-22520 */ }
|
||||||
specialFor(Primitives) {
|
specialFor(Primitives) {
|
||||||
if (primitive in shortIntPrimitives) {
|
if (primitive in shortIntPrimitives) {
|
||||||
body { "return Math.max(a.toInt(), Math.max(b.toInt(), c.toInt())).to$primitive()" }
|
body { "return Math.max(a.toInt(), Math.max(b.toInt(), c.toInt())).to$primitive()" }
|
||||||
|
|||||||
Reference in New Issue
Block a user