[K/N] Advance String(CharArray) deprecation level to ERROR

This commit is contained in:
Abduqodiri Qurbonzoda
2021-03-26 00:00:43 +03:00
parent d28d0a6321
commit 7a6cddf6fe
4 changed files with 5 additions and 3 deletions
@@ -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.
@@ -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())
}
@@ -15,5 +15,5 @@ import kotlin.test.*
print(" ")
}
println()
println(String(array, 0, array.size))
println(array.concatToString(0, array.size))
}
@@ -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()