From 7a6cddf6fe7609091656df1ab0c6e31a83063b7f Mon Sep 17 00:00:00 2001 From: Abduqodiri Qurbonzoda Date: Fri, 26 Mar 2021 00:00:43 +0300 Subject: [PATCH] [K/N] Advance String(CharArray) deprecation level to ERROR --- .../backend.native/tests/harmony_regex/AllCodePointsTest.kt | 2 +- kotlin-native/backend.native/tests/runtime/basic/hash0.kt | 2 +- kotlin-native/backend.native/tests/runtime/basic/tostring2.kt | 2 +- kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kotlin-native/backend.native/tests/harmony_regex/AllCodePointsTest.kt b/kotlin-native/backend.native/tests/harmony_regex/AllCodePointsTest.kt index 532d2958f12..8d20b0dae66 100644 --- a/kotlin-native/backend.native/tests/harmony_regex/AllCodePointsTest.kt +++ b/kotlin-native/backend.native/tests/harmony_regex/AllCodePointsTest.kt @@ -27,7 +27,7 @@ class AllCodePointsTest { fun codePointToString(codePoint: Int): String { val charArray = Char.toChars(codePoint) - return String(charArray, 0, charArray.size) + return charArray.concatToString(0, charArray.size) } // TODO: Here is a performance problem: an execution of this test requires much more time than it in Kotlin/JVM. diff --git a/kotlin-native/backend.native/tests/runtime/basic/hash0.kt b/kotlin-native/backend.native/tests/runtime/basic/hash0.kt index 42e576f1ce2..4bc72321ed0 100644 --- a/kotlin-native/backend.native/tests/runtime/basic/hash0.kt +++ b/kotlin-native/backend.native/tests/runtime/basic/hash0.kt @@ -22,5 +22,5 @@ import kotlin.test.* a[2] = 'l' a[3] = 'l' a[4] = 'o' - println("Hello".hashCode() == String(a, 0, 5).hashCode()) + println("Hello".hashCode() == a.concatToString(0, 5).hashCode()) } \ No newline at end of file diff --git a/kotlin-native/backend.native/tests/runtime/basic/tostring2.kt b/kotlin-native/backend.native/tests/runtime/basic/tostring2.kt index c767028700c..360b2b73a7d 100644 --- a/kotlin-native/backend.native/tests/runtime/basic/tostring2.kt +++ b/kotlin-native/backend.native/tests/runtime/basic/tostring2.kt @@ -15,5 +15,5 @@ import kotlin.test.* print(" ") } println() - println(String(array, 0, array.size)) + println(array.concatToString(0, array.size)) } \ No newline at end of file diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt index 63d14385ffb..ce66209b935 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/text/Strings.kt @@ -291,6 +291,7 @@ public actual fun CharSequence.repeat(n: Int): String { * Converts the characters in the specified array to a string. */ @Deprecated("Use CharArray.concatToString() instead", ReplaceWith("chars.concatToString()")) +@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5") public actual fun String(chars: CharArray): String = chars.concatToString() /** @@ -300,6 +301,7 @@ public actual fun String(chars: CharArray): String = chars.concatToString() * or `offset + length` is out of [chars] array bounds. */ @Deprecated("Use CharArray.concatToString(startIndex, endIndex) instead", ReplaceWith("chars.concatToString(offset, offset + length)")) +@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5") public actual fun String(chars: CharArray, offset: Int, length: Int): String { if (offset < 0 || length < 0 || offset + length > chars.size) throw ArrayIndexOutOfBoundsException()