Deprecate JS Array/PrimitiveArray.sort(comparison) functions

This commit is contained in:
Abduqodiri Qurbonzoda
2021-09-01 11:27:43 +03:00
committed by Space
parent a3eaa3e0f9
commit 0faa83bacb
5 changed files with 74 additions and 1 deletions
@@ -8341,6 +8341,8 @@ public fun kotlin.UShortArray.sliceArray(indices: kotlin.ranges.IntRange): kotli
public fun <T : kotlin.Comparable<T>> kotlin.Array<out T>.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use sortWith instead", replaceWith = kotlin.ReplaceWith(expression = "this.sortWith(Comparator(comparison))", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
public fun <T> kotlin.Array<out T>.sort(comparison: (a: T, b: T) -> kotlin.Int): kotlin.Unit
@kotlin.SinceKotlin(version = "1.4")
@@ -8349,6 +8351,8 @@ public fun <T : kotlin.Comparable<T>> kotlin.Array<out T>.sort(fromIndex: kotlin
/*∆*/ @kotlin.js.library(name = "primitiveArraySort")
public fun kotlin.ByteArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.ByteArray.sort(noinline comparison: (a: kotlin.Byte, b: kotlin.Byte) -> kotlin.Int): kotlin.Unit
@@ -8358,6 +8362,8 @@ public fun kotlin.ByteArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.In
/*∆*/ @kotlin.js.library(name = "primitiveArraySort")
public fun kotlin.CharArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.CharArray.sort(noinline comparison: (a: kotlin.Char, b: kotlin.Char) -> kotlin.Int): kotlin.Unit
@@ -8367,6 +8373,8 @@ public fun kotlin.CharArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.In
/*∆*/ @kotlin.js.library(name = "primitiveArraySort")
public fun kotlin.DoubleArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.DoubleArray.sort(noinline comparison: (a: kotlin.Double, b: kotlin.Double) -> kotlin.Int): kotlin.Unit
@@ -8376,6 +8384,8 @@ public fun kotlin.DoubleArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.
/*∆*/ @kotlin.js.library(name = "primitiveArraySort")
public fun kotlin.FloatArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.FloatArray.sort(noinline comparison: (a: kotlin.Float, b: kotlin.Float) -> kotlin.Int): kotlin.Unit
@@ -8385,6 +8395,8 @@ public fun kotlin.FloatArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.I
/*∆*/ @kotlin.js.library(name = "primitiveArraySort")
public fun kotlin.IntArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.IntArray.sort(noinline comparison: (a: kotlin.Int, b: kotlin.Int) -> kotlin.Int): kotlin.Unit
@@ -8393,6 +8405,8 @@ public fun kotlin.IntArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.Int
public fun kotlin.LongArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.LongArray.sort(noinline comparison: (a: kotlin.Long, b: kotlin.Long) -> kotlin.Int): kotlin.Unit
@@ -8402,6 +8416,8 @@ public fun kotlin.LongArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.In
/*∆*/ @kotlin.js.library(name = "primitiveArraySort")
public fun kotlin.ShortArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.ShortArray.sort(noinline comparison: (a: kotlin.Short, b: kotlin.Short) -> kotlin.Int): kotlin.Unit
@@ -8311,6 +8311,8 @@ public fun kotlin.UShortArray.sliceArray(indices: kotlin.ranges.IntRange): kotli
public fun <T : kotlin.Comparable<T>> kotlin.Array<out T>.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use sortWith instead", replaceWith = kotlin.ReplaceWith(expression = "this.sortWith(Comparator(comparison))", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
public fun <T> kotlin.Array<out T>.sort(comparison: (a: T, b: T) -> kotlin.Int): kotlin.Unit
@kotlin.SinceKotlin(version = "1.4")
@@ -8318,6 +8320,8 @@ public fun <T : kotlin.Comparable<T>> kotlin.Array<out T>.sort(fromIndex: kotlin
public fun kotlin.ByteArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.ByteArray.sort(noinline comparison: (a: kotlin.Byte, b: kotlin.Byte) -> kotlin.Int): kotlin.Unit
@@ -8326,6 +8330,8 @@ public fun kotlin.ByteArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.In
public fun kotlin.CharArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.CharArray.sort(noinline comparison: (a: kotlin.Char, b: kotlin.Char) -> kotlin.Int): kotlin.Unit
@@ -8334,6 +8340,8 @@ public fun kotlin.CharArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.In
public fun kotlin.DoubleArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.DoubleArray.sort(noinline comparison: (a: kotlin.Double, b: kotlin.Double) -> kotlin.Int): kotlin.Unit
@@ -8342,6 +8350,8 @@ public fun kotlin.DoubleArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.
public fun kotlin.FloatArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.FloatArray.sort(noinline comparison: (a: kotlin.Float, b: kotlin.Float) -> kotlin.Int): kotlin.Unit
@@ -8350,6 +8360,8 @@ public fun kotlin.FloatArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.I
public fun kotlin.IntArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.IntArray.sort(noinline comparison: (a: kotlin.Int, b: kotlin.Int) -> kotlin.Int): kotlin.Unit
@@ -8358,6 +8370,8 @@ public fun kotlin.IntArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.Int
public fun kotlin.LongArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.LongArray.sort(noinline comparison: (a: kotlin.Long, b: kotlin.Long) -> kotlin.Int): kotlin.Unit
@@ -8366,6 +8380,8 @@ public fun kotlin.LongArray.sort(fromIndex: kotlin.Int = ..., toIndex: kotlin.In
public fun kotlin.ShortArray.sort(): kotlin.Unit
@kotlin.Deprecated(message = "Use other sorting functions from the Standard Library")
@kotlin.DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun kotlin.ShortArray.sort(noinline comparison: (a: kotlin.Short, b: kotlin.Short) -> kotlin.Int): kotlin.Unit
@@ -1814,6 +1814,7 @@ public actual fun IntArray.sort(): Unit {
* @sample samples.collections.Arrays.Sorting.sortArray
*/
public actual fun LongArray.sort(): Unit {
@Suppress("DEPRECATION")
if (size > 1) sort { a: Long, b: Long -> a.compareTo(b) }
}
@@ -1878,6 +1879,8 @@ public actual fun <T : Comparable<T>> Array<out T>.sort(): Unit {
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
@Deprecated("Use sortWith instead", ReplaceWith("this.sortWith(Comparator(comparison))"))
@DeprecatedSinceKotlin(warningSince = "1.6")
public fun <T> Array<out T>.sort(comparison: (a: T, b: T) -> Int): Unit {
if (size > 1) sortArrayWith(this, comparison)
}
@@ -2036,6 +2039,8 @@ public actual fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun ByteArray.sort(noinline comparison: (a: Byte, b: Byte) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2044,6 +2049,8 @@ public inline fun ByteArray.sort(noinline comparison: (a: Byte, b: Byte) -> Int)
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun ShortArray.sort(noinline comparison: (a: Short, b: Short) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2052,6 +2059,8 @@ public inline fun ShortArray.sort(noinline comparison: (a: Short, b: Short) -> I
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun IntArray.sort(noinline comparison: (a: Int, b: Int) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2060,6 +2069,8 @@ public inline fun IntArray.sort(noinline comparison: (a: Int, b: Int) -> Int): U
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun LongArray.sort(noinline comparison: (a: Long, b: Long) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2068,6 +2079,8 @@ public inline fun LongArray.sort(noinline comparison: (a: Long, b: Long) -> Int)
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun FloatArray.sort(noinline comparison: (a: Float, b: Float) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2076,6 +2089,8 @@ public inline fun FloatArray.sort(noinline comparison: (a: Float, b: Float) -> I
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun DoubleArray.sort(noinline comparison: (a: Double, b: Double) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2084,6 +2099,8 @@ public inline fun DoubleArray.sort(noinline comparison: (a: Double, b: Double) -
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun CharArray.sort(noinline comparison: (a: Char, b: Char) -> Int): Unit {
asDynamic().sort(comparison)
@@ -1827,6 +1827,7 @@ public actual fun IntArray.sort(): Unit {
* @sample samples.collections.Arrays.Sorting.sortArray
*/
public actual fun LongArray.sort(): Unit {
@Suppress("DEPRECATION")
if (size > 1) sort { a: Long, b: Long -> a.compareTo(b) }
}
@@ -1896,6 +1897,8 @@ public actual fun <T : Comparable<T>> Array<out T>.sort(): Unit {
*
* The sort is _stable_. It means that equal elements preserve their order relative to each other after sorting.
*/
@Deprecated("Use sortWith instead", ReplaceWith("this.sortWith(Comparator(comparison))"))
@DeprecatedSinceKotlin(warningSince = "1.6")
public fun <T> Array<out T>.sort(comparison: (a: T, b: T) -> Int): Unit {
if (size > 1) sortArrayWith(this, comparison)
}
@@ -2055,6 +2058,8 @@ public actual fun CharArray.sort(fromIndex: Int = 0, toIndex: Int = size): Unit
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun ByteArray.sort(noinline comparison: (a: Byte, b: Byte) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2063,6 +2068,8 @@ public inline fun ByteArray.sort(noinline comparison: (a: Byte, b: Byte) -> Int)
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun ShortArray.sort(noinline comparison: (a: Short, b: Short) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2071,6 +2078,8 @@ public inline fun ShortArray.sort(noinline comparison: (a: Short, b: Short) -> I
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun IntArray.sort(noinline comparison: (a: Int, b: Int) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2079,6 +2088,8 @@ public inline fun IntArray.sort(noinline comparison: (a: Int, b: Int) -> Int): U
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun LongArray.sort(noinline comparison: (a: Long, b: Long) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2087,6 +2098,8 @@ public inline fun LongArray.sort(noinline comparison: (a: Long, b: Long) -> Int)
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun FloatArray.sort(noinline comparison: (a: Float, b: Float) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2095,6 +2108,8 @@ public inline fun FloatArray.sort(noinline comparison: (a: Float, b: Float) -> I
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun DoubleArray.sort(noinline comparison: (a: Double, b: Double) -> Int): Unit {
asDynamic().sort(comparison)
@@ -2103,6 +2118,8 @@ public inline fun DoubleArray.sort(noinline comparison: (a: Double, b: Double) -
/**
* Sorts the array in-place according to the order specified by the given [comparison] function.
*/
@Deprecated("Use other sorting functions from the Standard Library")
@DeprecatedSinceKotlin(warningSince = "1.6")
@kotlin.internal.InlineOnly
public inline fun CharArray.sort(noinline comparison: (a: Char, b: Char) -> Int): Unit {
asDynamic().sort(comparison)
@@ -1233,7 +1233,10 @@ object ArrayOps : TemplateGroupBase() {
}
} else {
body {
"""if (size > 1) sort { a: T, b: T -> a.compareTo(b) }"""
"""
@Suppress("DEPRECATION")
if (size > 1) sort { a: T, b: T -> a.compareTo(b) }
"""
}
}
}
@@ -1295,11 +1298,15 @@ object ArrayOps : TemplateGroupBase() {
returns("Unit")
doc { "Sorts the array in-place according to the order specified by the given [comparison] function." }
specialFor(ArraysOfPrimitives) {
deprecate(Deprecation("Use other sorting functions from the Standard Library", warningSince = "1.6"))
inlineOnly()
signature("sort(noinline comparison: (a: T, b: T) -> Int)")
body { "asDynamic().sort(comparison)" }
}
specialFor(ArraysOfObjects) {
deprecate(
Deprecation("Use sortWith instead", replaceWith = "this.sortWith(Comparator(comparison))", warningSince = "1.6")
)
appendStableSortNote()
body { """if (size > 1) sortArrayWith(this, comparison)""" }
}