diff --git a/libraries/stdlib/api/js-v1/kotlin.text.kt b/libraries/stdlib/api/js-v1/kotlin.text.kt index e41a15d5417..59d6ef9290c 100644 --- a/libraries/stdlib/api/js-v1/kotlin.text.kt +++ b/libraries/stdlib/api/js-v1/kotlin.text.kt @@ -123,6 +123,8 @@ public inline fun kotlin.CharSequence.associateWith(valueSelector: (kotlin.C @kotlin.SinceKotlin(version = "1.3") public inline fun > kotlin.CharSequence.associateWithTo(destination: M, valueSelector: (kotlin.Char) -> V): M +@kotlin.Deprecated(message = "Use replaceFirstChar instead.", replaceWith = kotlin.ReplaceWith(expression = "replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") public fun kotlin.String.capitalize(): kotlin.String @kotlin.SinceKotlin(version = "1.2") @@ -176,6 +178,8 @@ public inline fun kotlin.CharSequence.count(): kotlin.Int public inline fun kotlin.CharSequence.count(predicate: (kotlin.Char) -> kotlin.Boolean): kotlin.Int +@kotlin.Deprecated(message = "Use replaceFirstChar instead.", replaceWith = kotlin.ReplaceWith(expression = "replaceFirstChar { it.lowercase() }", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") public fun kotlin.String.decapitalize(): kotlin.String @kotlin.SinceKotlin(version = "1.4") @@ -1005,9 +1009,13 @@ public fun kotlin.String.toLongOrNull(): kotlin.Long? @kotlin.SinceKotlin(version = "1.1") public fun kotlin.String.toLongOrNull(radix: kotlin.Int): kotlin.Long? +@kotlin.Deprecated(message = "Use lowercaseChar() instead.", replaceWith = kotlin.ReplaceWith(expression = "lowercaseChar()", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun kotlin.Char.toLowerCase(): kotlin.Char +@kotlin.Deprecated(message = "Use lowercase() instead.", replaceWith = kotlin.ReplaceWith(expression = "lowercase()", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun kotlin.String.toLowerCase(): kotlin.String @@ -1128,9 +1136,13 @@ public fun kotlin.String.toUShortOrNull(): kotlin.UShort? @kotlin.WasExperimental(markerClass = {kotlin.ExperimentalUnsignedTypes::class}) public fun kotlin.String.toUShortOrNull(radix: kotlin.Int): kotlin.UShort? +@kotlin.Deprecated(message = "Use uppercaseChar() instead.", replaceWith = kotlin.ReplaceWith(expression = "uppercaseChar()", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun kotlin.Char.toUpperCase(): kotlin.Char +@kotlin.Deprecated(message = "Use uppercase() instead.", replaceWith = kotlin.ReplaceWith(expression = "uppercase()", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun kotlin.String.toUpperCase(): kotlin.String diff --git a/libraries/stdlib/api/js/kotlin.text.kt b/libraries/stdlib/api/js/kotlin.text.kt index e41a15d5417..59d6ef9290c 100644 --- a/libraries/stdlib/api/js/kotlin.text.kt +++ b/libraries/stdlib/api/js/kotlin.text.kt @@ -123,6 +123,8 @@ public inline fun kotlin.CharSequence.associateWith(valueSelector: (kotlin.C @kotlin.SinceKotlin(version = "1.3") public inline fun > kotlin.CharSequence.associateWithTo(destination: M, valueSelector: (kotlin.Char) -> V): M +@kotlin.Deprecated(message = "Use replaceFirstChar instead.", replaceWith = kotlin.ReplaceWith(expression = "replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") public fun kotlin.String.capitalize(): kotlin.String @kotlin.SinceKotlin(version = "1.2") @@ -176,6 +178,8 @@ public inline fun kotlin.CharSequence.count(): kotlin.Int public inline fun kotlin.CharSequence.count(predicate: (kotlin.Char) -> kotlin.Boolean): kotlin.Int +@kotlin.Deprecated(message = "Use replaceFirstChar instead.", replaceWith = kotlin.ReplaceWith(expression = "replaceFirstChar { it.lowercase() }", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") public fun kotlin.String.decapitalize(): kotlin.String @kotlin.SinceKotlin(version = "1.4") @@ -1005,9 +1009,13 @@ public fun kotlin.String.toLongOrNull(): kotlin.Long? @kotlin.SinceKotlin(version = "1.1") public fun kotlin.String.toLongOrNull(radix: kotlin.Int): kotlin.Long? +@kotlin.Deprecated(message = "Use lowercaseChar() instead.", replaceWith = kotlin.ReplaceWith(expression = "lowercaseChar()", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun kotlin.Char.toLowerCase(): kotlin.Char +@kotlin.Deprecated(message = "Use lowercase() instead.", replaceWith = kotlin.ReplaceWith(expression = "lowercase()", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun kotlin.String.toLowerCase(): kotlin.String @@ -1128,9 +1136,13 @@ public fun kotlin.String.toUShortOrNull(): kotlin.UShort? @kotlin.WasExperimental(markerClass = {kotlin.ExperimentalUnsignedTypes::class}) public fun kotlin.String.toUShortOrNull(radix: kotlin.Int): kotlin.UShort? +@kotlin.Deprecated(message = "Use uppercaseChar() instead.", replaceWith = kotlin.ReplaceWith(expression = "uppercaseChar()", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun kotlin.Char.toUpperCase(): kotlin.Char +@kotlin.Deprecated(message = "Use uppercase() instead.", replaceWith = kotlin.ReplaceWith(expression = "uppercase()", imports = {})) +@kotlin.DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun kotlin.String.toUpperCase(): kotlin.String diff --git a/libraries/stdlib/js/src/kotlin/text/char.kt b/libraries/stdlib/js/src/kotlin/text/char.kt index 3bcdd262aab..f95a1242ead 100644 --- a/libraries/stdlib/js/src/kotlin/text/char.kt +++ b/libraries/stdlib/js/src/kotlin/text/char.kt @@ -8,7 +8,8 @@ package kotlin.text /** * Converts this character to lower case using Unicode mapping rules of the invariant locale. */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use lowercaseChar() instead.", ReplaceWith("lowercaseChar()")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public actual inline fun Char.toLowerCase(): Char = lowercaseChar() @@ -44,7 +45,8 @@ public actual inline fun Char.lowercase(): String = toString().asDynamic().toLow /** * Converts this character to upper case using Unicode mapping rules of the invariant locale. */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use uppercaseChar() instead.", ReplaceWith("uppercaseChar()")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public actual inline fun Char.toUpperCase(): Char = uppercaseChar() diff --git a/libraries/stdlib/js/src/kotlin/text/string.kt b/libraries/stdlib/js/src/kotlin/text/string.kt index 6aa130913dd..f054a464d49 100644 --- a/libraries/stdlib/js/src/kotlin/text/string.kt +++ b/libraries/stdlib/js/src/kotlin/text/string.kt @@ -171,6 +171,8 @@ public actual fun String.encodeToByteArray( /** * Returns a copy of this string converted to upper case using the rules of the default locale. */ +@Deprecated("Use uppercase() instead.", ReplaceWith("uppercase()")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public actual inline fun String.toUpperCase(): String = asDynamic().toUpperCase() @@ -190,6 +192,8 @@ public actual inline fun String.uppercase(): String = asDynamic().toUpperCase() /** * Returns a copy of this string converted to lower case using the rules of the default locale. */ +@Deprecated("Use lowercase() instead.", ReplaceWith("lowercase()")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public actual inline fun String.toLowerCase(): String = asDynamic().toLowerCase() diff --git a/libraries/stdlib/js/src/kotlin/text/stringsCode.kt b/libraries/stdlib/js/src/kotlin/text/stringsCode.kt index 5e9d408f06c..302b9943df8 100644 --- a/libraries/stdlib/js/src/kotlin/text/stringsCode.kt +++ b/libraries/stdlib/js/src/kotlin/text/stringsCode.kt @@ -83,6 +83,8 @@ public actual fun CharSequence.regionMatches(thisOffset: Int, other: CharSequenc * * @sample samples.text.Strings.capitalize */ +@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }")) +@DeprecatedSinceKotlin(warningSince = "1.5") public actual fun String.capitalize(): String { return if (isNotEmpty()) substring(0, 1).toUpperCase() + substring(1) else this } @@ -93,6 +95,8 @@ public actual fun String.capitalize(): String { * * @sample samples.text.Strings.decapitalize */ +@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { it.lowercase() }")) +@DeprecatedSinceKotlin(warningSince = "1.5") public actual fun String.decapitalize(): String { return if (isNotEmpty()) substring(0, 1).toLowerCase() + substring(1) else this } diff --git a/libraries/stdlib/jvm/src/kotlin/text/CharJVM.kt b/libraries/stdlib/jvm/src/kotlin/text/CharJVM.kt index 49230571e54..02f3bdd1cab 100644 --- a/libraries/stdlib/jvm/src/kotlin/text/CharJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/text/CharJVM.kt @@ -113,7 +113,8 @@ public actual inline fun Char.isLowerCase(): Boolean = Character.isLowerCase(thi /** * Converts this character to lower case using Unicode mapping rules of the invariant locale. */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use uppercaseChar() instead.", ReplaceWith("uppercaseChar()")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public actual inline fun Char.toUpperCase(): Char = uppercaseChar() @@ -163,7 +164,8 @@ public fun Char.uppercase(locale: Locale): String = toString().uppercase(locale) /** * Converts this character to lower case using Unicode mapping rules of the invariant locale. */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use lowercaseChar() instead.", ReplaceWith("lowercaseChar()")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public actual inline fun Char.toLowerCase(): Char = lowercaseChar() @@ -222,7 +224,8 @@ public actual inline fun Char.isTitleCase(): Boolean = Character.isTitleCase(thi * * @see Character.toTitleCase */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use titlecaseChar() instead.", ReplaceWith("titlecaseChar()")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun Char.toTitleCase(): Char = titlecaseChar() diff --git a/libraries/stdlib/jvm/src/kotlin/text/StringsJVM.kt b/libraries/stdlib/jvm/src/kotlin/text/StringsJVM.kt index 8b49763998b..4270135ebe8 100644 --- a/libraries/stdlib/jvm/src/kotlin/text/StringsJVM.kt +++ b/libraries/stdlib/jvm/src/kotlin/text/StringsJVM.kt @@ -121,6 +121,8 @@ public actual fun String.replaceFirst(oldValue: String, newValue: String, ignore /** * Returns a copy of this string converted to upper case using the rules of the default locale. */ +@Deprecated("Use uppercase() instead.", ReplaceWith("uppercase(Locale.getDefault())", "java.util.Locale")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public actual inline fun String.toUpperCase(): String = (this as java.lang.String).toUpperCase() @@ -140,6 +142,8 @@ public actual inline fun String.uppercase(): String = (this as java.lang.String) /** * Returns a copy of this string converted to lower case using the rules of the default locale. */ +@Deprecated("Use lowercase() instead.", ReplaceWith("lowercase(Locale.getDefault())", "java.util.Locale")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public actual inline fun String.toLowerCase(): String = (this as java.lang.String).toLowerCase() @@ -645,7 +649,8 @@ public fun String.regionMatches(thisOffset: Int, other: String, otherOffset: Int /** * Returns a copy of this string converted to lower case using the rules of the specified locale. */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use lowercase() instead.", ReplaceWith("lowercase(locale)")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun String.toLowerCase(locale: java.util.Locale): String = lowercase(locale) @@ -665,7 +670,8 @@ public inline fun String.lowercase(locale: Locale): String = (this as java.lang. /** * Returns a copy of this string converted to upper case using the rules of the specified locale. */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use uppercase() instead.", ReplaceWith("uppercase(locale)")) +@DeprecatedSinceKotlin(warningSince = "1.5") @kotlin.internal.InlineOnly public inline fun String.toUpperCase(locale: java.util.Locale): String = uppercase(locale) @@ -708,6 +714,8 @@ public inline fun String.toPattern(flags: Int = 0): java.util.regex.Pattern { * * @sample samples.text.Strings.capitalize */ +@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() }", "java.util.Locale")) +@DeprecatedSinceKotlin(warningSince = "1.5") public actual fun String.capitalize(): String { return capitalize(Locale.getDefault()) } @@ -719,7 +727,8 @@ public actual fun String.capitalize(): String { * The title case of a character is usually the same as its upper case with several exceptions. * The particular list of characters with the special title case form depends on the underlying platform. */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { if (it.isLowerCase()) it.titlecase(locale) else it.toString() }")) +@DeprecatedSinceKotlin(warningSince = "1.5") @SinceKotlin("1.4") @WasExperimental(ExperimentalStdlibApi::class) @kotlin.internal.LowPriorityInOverloadResolution // To avoid conflicts in function references, as this function was introduced later than common capitalize() @@ -747,6 +756,8 @@ public fun String.capitalize(locale: Locale): String { * * @sample samples.text.Strings.decapitalize */ +@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { it.lowercase(Locale.getDefault()) }", "java.util.Locale")) +@DeprecatedSinceKotlin(warningSince = "1.5") public actual fun String.decapitalize(): String { return if (isNotEmpty() && !this[0].isLowerCase()) substring(0, 1).toLowerCase() + substring(1) else this } @@ -755,7 +766,8 @@ public actual fun String.decapitalize(): String { * Returns a copy of this string having its first letter lowercased using the rules of the specified [locale], * or the original string, if it's empty or already starts with a lower case letter. */ -@OptIn(ExperimentalStdlibApi::class) +@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { it.lowercase(locale) }")) +@DeprecatedSinceKotlin(warningSince = "1.5") @SinceKotlin("1.4") @WasExperimental(ExperimentalStdlibApi::class) @kotlin.internal.LowPriorityInOverloadResolution // To avoid conflicts in function references, as this function was introduced later than common decapitalize() diff --git a/libraries/stdlib/src/kotlin/text/Char.kt b/libraries/stdlib/src/kotlin/text/Char.kt index 5510b21b355..134d43071f5 100644 --- a/libraries/stdlib/src/kotlin/text/Char.kt +++ b/libraries/stdlib/src/kotlin/text/Char.kt @@ -120,6 +120,8 @@ public fun Int.digitToChar(radix: Int): Char { /** * Converts this character to lower case using Unicode mapping rules of the invariant locale. */ +@Deprecated("Use lowercaseChar() instead.", ReplaceWith("lowercaseChar()")) +@DeprecatedSinceKotlin(warningSince = "1.5") public expect fun Char.toLowerCase(): Char /** @@ -152,6 +154,8 @@ public expect fun Char.lowercase(): String /** * Converts this character to upper case using Unicode mapping rules of the invariant locale. */ +@Deprecated("Use uppercaseChar() instead.", ReplaceWith("uppercaseChar()")) +@DeprecatedSinceKotlin(warningSince = "1.5") public expect fun Char.toUpperCase(): Char /** diff --git a/libraries/stdlib/src/kotlin/text/Strings.kt b/libraries/stdlib/src/kotlin/text/Strings.kt index c22576378bc..027e55ae47b 100644 --- a/libraries/stdlib/src/kotlin/text/Strings.kt +++ b/libraries/stdlib/src/kotlin/text/Strings.kt @@ -14,6 +14,8 @@ import kotlin.jvm.JvmName /** * Returns a copy of this string converted to upper case using the rules of the default locale. */ +@Deprecated("Use uppercase() instead.", ReplaceWith("uppercase()")) +@DeprecatedSinceKotlin(warningSince = "1.5") public expect fun String.toUpperCase(): String /** @@ -31,6 +33,8 @@ public expect fun String.uppercase(): String /** * Returns a copy of this string converted to lower case using the rules of the default locale. */ +@Deprecated("Use lowercase() instead.", ReplaceWith("lowercase()")) +@DeprecatedSinceKotlin(warningSince = "1.5") public expect fun String.toLowerCase(): String /** @@ -54,6 +58,8 @@ public expect fun String.lowercase(): String * * @sample samples.text.Strings.capitalize */ +@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { if (it.isLowerCase()) it.titlecase() else it.toString() }")) +@DeprecatedSinceKotlin(warningSince = "1.5") public expect fun String.capitalize(): String /** @@ -62,6 +68,8 @@ public expect fun String.capitalize(): String * * @sample samples.text.Strings.decapitalize */ +@Deprecated("Use replaceFirstChar instead.", ReplaceWith("replaceFirstChar { it.lowercase() }")) +@DeprecatedSinceKotlin(warningSince = "1.5") public expect fun String.decapitalize(): String /**