Advance String(CharArray) deprecation level to ERROR in Common and JS
This commit is contained in:
+1
-1
@@ -8,6 +8,6 @@ inline fun foo(mkString: () -> String): String =
|
||||
mkString()
|
||||
|
||||
fun bar (xs: CharArray = charArrayOf('O','K')) =
|
||||
String(xs)
|
||||
xs.concatToString()
|
||||
|
||||
fun box(): String = foo(::bar)
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ inline fun foo(mkString: (Char, Char) -> String): String =
|
||||
mkString('O','K')
|
||||
|
||||
fun bar (vararg xs: Char) =
|
||||
String(xs)
|
||||
xs.concatToString()
|
||||
|
||||
fun box(): String = foo(::bar)
|
||||
// -> { a, b -> bar(a, b) }
|
||||
+1
-1
@@ -11,7 +11,7 @@ inline fun foo(mkString: () -> String): String =
|
||||
mkString()
|
||||
|
||||
inline fun bar (xs: CharArray = charArrayOf('O','K')) =
|
||||
String(xs)
|
||||
xs.concatToString()
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
@@ -18,10 +18,12 @@ public fun Regex_1(pattern: kotlin.String): kotlin.text.Regex
|
||||
|
||||
@kotlin.SinceKotlin(version = "1.2")
|
||||
@kotlin.Deprecated(message = "Use CharArray.concatToString() instead", replaceWith = kotlin.ReplaceWith(expression = "chars.concatToString()", imports = {}))
|
||||
@kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.4")
|
||||
public fun String(chars: kotlin.CharArray): kotlin.String
|
||||
|
||||
@kotlin.SinceKotlin(version = "1.2")
|
||||
@kotlin.Deprecated(message = "Use CharArray.concatToString(startIndex, endIndex) instead", replaceWith = kotlin.ReplaceWith(expression = "chars.concatToString(offset, offset + length)", imports = {}))
|
||||
@kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.4")
|
||||
public fun String(chars: kotlin.CharArray, offset: kotlin.Int, length: kotlin.Int): kotlin.String
|
||||
|
||||
@kotlin.SinceKotlin(version = "1.1")
|
||||
|
||||
@@ -18,10 +18,12 @@ public fun Regex_1(pattern: kotlin.String): kotlin.text.Regex
|
||||
|
||||
@kotlin.SinceKotlin(version = "1.2")
|
||||
@kotlin.Deprecated(message = "Use CharArray.concatToString() instead", replaceWith = kotlin.ReplaceWith(expression = "chars.concatToString()", imports = {}))
|
||||
@kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.4")
|
||||
public fun String(chars: kotlin.CharArray): kotlin.String
|
||||
|
||||
@kotlin.SinceKotlin(version = "1.2")
|
||||
@kotlin.Deprecated(message = "Use CharArray.concatToString(startIndex, endIndex) instead", replaceWith = kotlin.ReplaceWith(expression = "chars.concatToString(offset, offset + length)", imports = {}))
|
||||
@kotlin.DeprecatedSinceKotlin(errorSince = "1.5", warningSince = "1.4")
|
||||
public fun String(chars: kotlin.CharArray, offset: kotlin.Int, length: kotlin.Int): kotlin.String
|
||||
|
||||
@kotlin.SinceKotlin(version = "1.1")
|
||||
|
||||
@@ -74,6 +74,7 @@ expect fun Char.isLowSurrogate(): Boolean
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
@Deprecated("Use CharArray.concatToString() instead", ReplaceWith("chars.concatToString()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5")
|
||||
public expect fun String(chars: CharArray): String
|
||||
|
||||
/**
|
||||
@@ -84,6 +85,7 @@ public expect fun String(chars: CharArray): String
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
@Deprecated("Use CharArray.concatToString(startIndex, endIndex) instead", ReplaceWith("chars.concatToString(offset, offset + length)"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5")
|
||||
public expect fun String(chars: CharArray, offset: Int, length: Int): String
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,6 +12,7 @@ import kotlin.js.RegExp
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
@Deprecated("Use CharArray.concatToString() instead", ReplaceWith("chars.concatToString()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5")
|
||||
public actual fun String(chars: CharArray): String {
|
||||
var result = ""
|
||||
for (char in chars) {
|
||||
@@ -28,6 +29,7 @@ public actual fun String(chars: CharArray): String {
|
||||
*/
|
||||
@SinceKotlin("1.2")
|
||||
@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 || chars.size - offset < length)
|
||||
throw IndexOutOfBoundsException("size: ${chars.size}; offset: $offset; length: $length")
|
||||
|
||||
@@ -47,13 +47,13 @@ fun Char.isAsciiUpperCase() = this in 'A'..'Z'
|
||||
|
||||
class StringTest {
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
private fun testStringFromChars(expected: String, chars: CharArray, offset: Int, length: Int) {
|
||||
assertEquals(expected, String(chars, offset, length))
|
||||
assertEquals(expected, chars.concatToString(startIndex = offset, endIndex = offset + length))
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
private fun testStringFromChars(expected: String, chars: CharArray) {
|
||||
assertEquals(expected, String(chars))
|
||||
assertEquals(expected, chars.concatToString())
|
||||
@@ -64,7 +64,7 @@ class StringTest {
|
||||
testStringFromChars("Kotlin", chars, 0, chars.size)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@Test fun stringFromCharArraySlice() {
|
||||
val chars: CharArray = charArrayOf('K', 'o', 't', 'l', 'i', 'n', ' ', 'r', 'u', 'l', 'e', 's')
|
||||
testStringFromChars("rule", chars, 7, 4)
|
||||
@@ -78,7 +78,7 @@ class StringTest {
|
||||
assertTrue(longConcatString.all { it == 'k' })
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@Test fun stringFromCharArray() {
|
||||
val chars: CharArray = charArrayOf('K', 'o', 't', 'l', 'i', 'n')
|
||||
testStringFromChars("Kotlin", chars)
|
||||
@@ -99,7 +99,7 @@ class StringTest {
|
||||
testStringFromChars("Ŭᎍ🀺", chars, 3, 4)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Suppress("DEPRECATION_ERROR")
|
||||
@Test fun stringFromCharArrayOutOfBounds() {
|
||||
fun test(chars: CharArray) {
|
||||
assertFailsWith<IndexOutOfBoundsException> { String(chars, -1, 1) }
|
||||
|
||||
Reference in New Issue
Block a user