Remove String.format with non-null locale
Introducing new overloads with @SinceKotlin(1.4) annotation and marking the old ones @LowPriorityInOverloadResolution breaks all code that uses the format(locale, args) overload with -api-version 1.3. Because the low priority of the non-1.4 version makes format(args) preferable in all cases. For example, "%02X".format(Locale.ROOT, 1) throws IllegalFormatConversionException: x != java.util.Locale.
This commit is contained in:
@@ -15,7 +15,6 @@ import java.nio.charset.Charset
|
|||||||
import java.nio.charset.CodingErrorAction
|
import java.nio.charset.CodingErrorAction
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
import kotlin.internal.LowPriorityInOverloadResolution
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -285,38 +284,17 @@ public inline fun String.format(vararg args: Any?): String = java.lang.String.fo
|
|||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String.Companion.format(format: String, vararg args: Any?): String = java.lang.String.format(format, *args)
|
public inline fun String.Companion.format(format: String, vararg args: Any?): String = java.lang.String.format(format, *args)
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses this string as a format string and returns a string obtained by substituting the specified arguments,
|
|
||||||
* using the specified locale.
|
|
||||||
*/
|
|
||||||
@LowPriorityInOverloadResolution
|
|
||||||
@kotlin.internal.InlineOnly
|
|
||||||
public inline fun String.format(locale: Locale, vararg args: Any?): String = java.lang.String.format(locale, this, *args)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses this string as a format string and returns a string obtained by substituting the specified arguments,
|
* Uses this string as a format string and returns a string obtained by substituting the specified arguments,
|
||||||
* using the specified locale. If [locale] is `null` then no localization is applied.
|
* using the specified locale. If [locale] is `null` then no localization is applied.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.4")
|
|
||||||
@JvmName("formatNullable")
|
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String.format(locale: Locale?, vararg args: Any?): String = java.lang.String.format(locale, this, *args)
|
public inline fun String.format(locale: Locale?, vararg args: Any?): String = java.lang.String.format(locale, this, *args)
|
||||||
|
|
||||||
/**
|
|
||||||
* Uses the provided [format] as a format string and returns a string obtained by substituting the specified arguments,
|
|
||||||
* using the specified locale.
|
|
||||||
*/
|
|
||||||
@LowPriorityInOverloadResolution
|
|
||||||
@kotlin.internal.InlineOnly
|
|
||||||
public inline fun String.Companion.format(locale: Locale, format: String, vararg args: Any?): String =
|
|
||||||
java.lang.String.format(locale, format, *args)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses the provided [format] as a format string and returns a string obtained by substituting the specified arguments,
|
* Uses the provided [format] as a format string and returns a string obtained by substituting the specified arguments,
|
||||||
* using the specified locale. If [locale] is `null` then no localization is applied.
|
* using the specified locale. If [locale] is `null` then no localization is applied.
|
||||||
*/
|
*/
|
||||||
@SinceKotlin("1.4")
|
|
||||||
@JvmName("formatNullable")
|
|
||||||
@kotlin.internal.InlineOnly
|
@kotlin.internal.InlineOnly
|
||||||
public inline fun String.Companion.format(locale: Locale?, format: String, vararg args: Any?): String =
|
public inline fun String.Companion.format(locale: Locale?, format: String, vararg args: Any?): String =
|
||||||
java.lang.String.format(locale, format, *args)
|
java.lang.String.format(locale, format, *args)
|
||||||
|
|||||||
Reference in New Issue
Block a user