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
@@ -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)""" }
}