From bde055fe5c6be9816b4126133a12fb41eae0e0cf Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Mon, 13 Sep 2021 17:32:17 +0300 Subject: [PATCH] Advance deprecation level of Float/DoubleArray contains, indexOf, lastIndexOf to ERROR #KT-28753 --- libraries/stdlib/api/js-v1/kotlin.collections.kt | 12 ++++++------ libraries/stdlib/api/js/kotlin.collections.kt | 12 ++++++------ libraries/stdlib/common/src/generated/_Arrays.kt | 16 ++++++++-------- libraries/stdlib/test/collections/ArraysTest.kt | 2 +- .../kotlin-stdlib-gen/src/templates/Elements.kt | 8 ++++---- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/libraries/stdlib/api/js-v1/kotlin.collections.kt b/libraries/stdlib/api/js-v1/kotlin.collections.kt index 5e228967a16..feea90efb63 100644 --- a/libraries/stdlib/api/js-v1/kotlin.collections.kt +++ b/libraries/stdlib/api/js-v1/kotlin.collections.kt @@ -1044,11 +1044,11 @@ public operator fun kotlin.ByteArray.contains(element: kotlin.Byte): kotlin.Bool public operator fun kotlin.CharArray.contains(element: kotlin.Char): kotlin.Boolean @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "any { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public operator fun kotlin.DoubleArray.contains(element: kotlin.Double): kotlin.Boolean @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "any { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public operator fun kotlin.FloatArray.contains(element: kotlin.Float): kotlin.Boolean public operator fun kotlin.IntArray.contains(element: kotlin.Int): kotlin.Boolean @@ -3513,11 +3513,11 @@ public fun kotlin.ByteArray.indexOf(element: kotlin.Byte): kotlin.Int public fun kotlin.CharArray.indexOf(element: kotlin.Char): kotlin.Int @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "indexOfFirst { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public fun kotlin.DoubleArray.indexOf(element: kotlin.Double): kotlin.Int @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "indexOfFirst { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public fun kotlin.FloatArray.indexOf(element: kotlin.Float): kotlin.Int public fun kotlin.IntArray.indexOf(element: kotlin.Int): kotlin.Int @@ -3872,11 +3872,11 @@ public fun kotlin.ByteArray.lastIndexOf(element: kotlin.Byte): kotlin.Int public fun kotlin.CharArray.lastIndexOf(element: kotlin.Char): kotlin.Int @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfLast { it == element }' instead to continue using this behavior, or '.asList().lastIndexOf(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "indexOfLast { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public fun kotlin.DoubleArray.lastIndexOf(element: kotlin.Double): kotlin.Int @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfLast { it == element }' instead to continue using this behavior, or '.asList().lastIndexOf(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "indexOfLast { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public fun kotlin.FloatArray.lastIndexOf(element: kotlin.Float): kotlin.Int public fun kotlin.IntArray.lastIndexOf(element: kotlin.Int): kotlin.Int diff --git a/libraries/stdlib/api/js/kotlin.collections.kt b/libraries/stdlib/api/js/kotlin.collections.kt index fb819be9f59..77a74bc6dae 100644 --- a/libraries/stdlib/api/js/kotlin.collections.kt +++ b/libraries/stdlib/api/js/kotlin.collections.kt @@ -1044,11 +1044,11 @@ public operator fun kotlin.ByteArray.contains(element: kotlin.Byte): kotlin.Bool public operator fun kotlin.CharArray.contains(element: kotlin.Char): kotlin.Boolean @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "any { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public operator fun kotlin.DoubleArray.contains(element: kotlin.Double): kotlin.Boolean @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "any { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public operator fun kotlin.FloatArray.contains(element: kotlin.Float): kotlin.Boolean public operator fun kotlin.IntArray.contains(element: kotlin.Int): kotlin.Boolean @@ -3483,11 +3483,11 @@ public fun kotlin.ByteArray.indexOf(element: kotlin.Byte): kotlin.Int public fun kotlin.CharArray.indexOf(element: kotlin.Char): kotlin.Int @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "indexOfFirst { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public fun kotlin.DoubleArray.indexOf(element: kotlin.Double): kotlin.Int @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "indexOfFirst { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public fun kotlin.FloatArray.indexOf(element: kotlin.Float): kotlin.Int public fun kotlin.IntArray.indexOf(element: kotlin.Int): kotlin.Int @@ -3842,11 +3842,11 @@ public fun kotlin.ByteArray.lastIndexOf(element: kotlin.Byte): kotlin.Int public fun kotlin.CharArray.lastIndexOf(element: kotlin.Char): kotlin.Int @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfLast { it == element }' instead to continue using this behavior, or '.asList().lastIndexOf(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "indexOfLast { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public fun kotlin.DoubleArray.lastIndexOf(element: kotlin.Double): kotlin.Int @kotlin.Deprecated(message = "The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfLast { it == element }' instead to continue using this behavior, or '.asList().lastIndexOf(element: T)' to get the same search behavior as in a list.", replaceWith = kotlin.ReplaceWith(expression = "indexOfLast { it == element }", imports = {})) -@kotlin.DeprecatedSinceKotlin(warningSince = "1.4") +@kotlin.DeprecatedSinceKotlin(errorSince = "1.6", warningSince = "1.4") public fun kotlin.FloatArray.lastIndexOf(element: kotlin.Float): kotlin.Int public fun kotlin.IntArray.lastIndexOf(element: kotlin.Int): kotlin.Int diff --git a/libraries/stdlib/common/src/generated/_Arrays.kt b/libraries/stdlib/common/src/generated/_Arrays.kt index f699db7f209..c79033f150f 100644 --- a/libraries/stdlib/common/src/generated/_Arrays.kt +++ b/libraries/stdlib/common/src/generated/_Arrays.kt @@ -551,8 +551,8 @@ public operator fun LongArray.contains(element: Long): Boolean { * Returns `true` if [element] is found in the array. */ @Deprecated("The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list.", ReplaceWith("any { it == element }")) -@DeprecatedSinceKotlin(warningSince = "1.4") -@Suppress("DEPRECATION") +@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6") +@Suppress("DEPRECATION_ERROR") public operator fun FloatArray.contains(element: Float): Boolean { return indexOf(element) >= 0 } @@ -561,8 +561,8 @@ public operator fun FloatArray.contains(element: Float): Boolean { * Returns `true` if [element] is found in the array. */ @Deprecated("The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'any { it == element }' instead to continue using this behavior, or '.asList().contains(element: T)' to get the same search behavior as in a list.", ReplaceWith("any { it == element }")) -@DeprecatedSinceKotlin(warningSince = "1.4") -@Suppress("DEPRECATION") +@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6") +@Suppress("DEPRECATION_ERROR") public operator fun DoubleArray.contains(element: Double): Boolean { return indexOf(element) >= 0 } @@ -1565,7 +1565,7 @@ public fun LongArray.indexOf(element: Long): Int { * Returns first index of [element], or -1 if the array does not contain element. */ @Deprecated("The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list.", ReplaceWith("indexOfFirst { it == element }")) -@DeprecatedSinceKotlin(warningSince = "1.4") +@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6") public fun FloatArray.indexOf(element: Float): Int { for (index in indices) { if (element == this[index]) { @@ -1579,7 +1579,7 @@ public fun FloatArray.indexOf(element: Float): Int { * Returns first index of [element], or -1 if the array does not contain element. */ @Deprecated("The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfFirst { it == element }' instead to continue using this behavior, or '.asList().indexOf(element: T)' to get the same search behavior as in a list.", ReplaceWith("indexOfFirst { it == element }")) -@DeprecatedSinceKotlin(warningSince = "1.4") +@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6") public fun DoubleArray.indexOf(element: Double): Int { for (index in indices) { if (element == this[index]) { @@ -2153,7 +2153,7 @@ public fun LongArray.lastIndexOf(element: Long): Int { * Returns last index of [element], or -1 if the array does not contain element. */ @Deprecated("The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfLast { it == element }' instead to continue using this behavior, or '.asList().lastIndexOf(element: T)' to get the same search behavior as in a list.", ReplaceWith("indexOfLast { it == element }")) -@DeprecatedSinceKotlin(warningSince = "1.4") +@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6") public fun FloatArray.lastIndexOf(element: Float): Int { for (index in indices.reversed()) { if (element == this[index]) { @@ -2167,7 +2167,7 @@ public fun FloatArray.lastIndexOf(element: Float): Int { * Returns last index of [element], or -1 if the array does not contain element. */ @Deprecated("The function has unclear behavior when searching for NaN or zero values and will be removed soon. Use 'indexOfLast { it == element }' instead to continue using this behavior, or '.asList().lastIndexOf(element: T)' to get the same search behavior as in a list.", ReplaceWith("indexOfLast { it == element }")) -@DeprecatedSinceKotlin(warningSince = "1.4") +@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.6") public fun DoubleArray.lastIndexOf(element: Double): Int { for (index in indices.reversed()) { if (element == this[index]) { diff --git a/libraries/stdlib/test/collections/ArraysTest.kt b/libraries/stdlib/test/collections/ArraysTest.kt index 365679b2420..0bd0bb9fcac 100644 --- a/libraries/stdlib/test/collections/ArraysTest.kt +++ b/libraries/stdlib/test/collections/ArraysTest.kt @@ -502,7 +502,7 @@ class ArraysTest { // for each arr with size > 0 arr.average() = arr.sum().toDouble() / arr.size() } - @Suppress("DEPRECATION") + @Suppress("DEPRECATION_ERROR") @Test fun indexOfInPrimitiveArrays() { expect(-1) { byteArrayOf(1, 2, 3).indexOf(0) } expect(0) { byteArrayOf(1, 2, 3).indexOf(1) } diff --git a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt index 2c0f903397a..d4ecee50749 100644 --- a/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt +++ b/libraries/tools/kotlin-stdlib-gen/src/templates/Elements.kt @@ -43,8 +43,8 @@ object Elements : TemplateGroupBase() { if (f == ArraysOfPrimitives && primitive!!.isFloatingPoint()) { val replacement = "any { it == element }" val message = floatingSearchDeprecationMessage(signature, replacement) - deprecate(Deprecation(message, replacement, warningSince = "1.4")) - annotation("""@Suppress("DEPRECATION")""") + deprecate(Deprecation(message, replacement, warningSince = "1.4", errorSince = "1.6")) + annotation("""@Suppress("DEPRECATION_ERROR")""") } returns("Boolean") body(Iterables) { @@ -72,7 +72,7 @@ object Elements : TemplateGroupBase() { if (f == ArraysOfPrimitives && primitive!!.isFloatingPoint()) { val replacement = "indexOfFirst { it == element }" val message = floatingSearchDeprecationMessage(signature, replacement) - deprecate(Deprecation(message, replacement, warningSince = "1.4")) + deprecate(Deprecation(message, replacement, warningSince = "1.4", errorSince = "1.6")) } returns("Int") body { @@ -137,7 +137,7 @@ object Elements : TemplateGroupBase() { if (f == ArraysOfPrimitives && primitive!!.isFloatingPoint()) { val replacement = "indexOfLast { it == element }" val message = floatingSearchDeprecationMessage(signature, replacement) - deprecate(Deprecation(message, replacement, warningSince = "1.4")) + deprecate(Deprecation(message, replacement, warningSince = "1.4", errorSince = "1.6")) } returns("Int") body {