[Stdlib] Deprecate and make open Number.toChar()

^KT-46465 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-02-21 12:53:58 +02:00
committed by Space Team
parent 90ec84d7b7
commit a64d8e8a31
30 changed files with 399 additions and 72 deletions
+10 -6
View File
@@ -1135,7 +1135,7 @@ public final class Byte : kotlin.Number, kotlin.Comparable<kotlin.Byte> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
public open override fun toChar(): kotlin.Char
@@ -1524,7 +1524,7 @@ public final class Double : kotlin.Number, kotlin.Comparable<kotlin.Double> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
public open override fun toChar(): kotlin.Char
@@ -1819,7 +1819,7 @@ public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
public open override fun toChar(): kotlin.Char
@@ -2348,7 +2348,7 @@ public final class Long : kotlin.Number, kotlin.Comparable<kotlin.Long> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
public open override fun toChar(): kotlin.Char
@@ -2443,7 +2443,11 @@ public abstract class Number {
public abstract fun toByte(): kotlin.Byte
public abstract fun toChar(): kotlin.Char
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.
If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it.
See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.9")
public open fun toChar(): kotlin.Char
public abstract fun toDouble(): kotlin.Double
@@ -2766,7 +2770,7 @@ public final class Short : kotlin.Number, kotlin.Comparable<kotlin.Short> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
/*∆*/ @kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
/*∆*/ @kotlin.internal.IntrinsicConstEvaluation
public open override fun toChar(): kotlin.Char
+10 -5
View File
@@ -1051,7 +1051,7 @@ public final class Byte : kotlin.Number, kotlin.Comparable<kotlin.Byte> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
public open override fun toChar(): kotlin.Char
public open override fun toDouble(): kotlin.Double
@@ -1381,7 +1381,7 @@ public final class Double : kotlin.Number, kotlin.Comparable<kotlin.Double> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
public open override fun toChar(): kotlin.Char
public open override fun toDouble(): kotlin.Double
@@ -1612,7 +1612,7 @@ public final class Float : kotlin.Number, kotlin.Comparable<kotlin.Float> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
public open override fun toChar(): kotlin.Char
public open override fun toDouble(): kotlin.Double
@@ -2037,7 +2037,7 @@ public final class Long : kotlin.Number, kotlin.Comparable<kotlin.Long> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(warningSince = "1.5")
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
public open override fun toChar(): kotlin.Char
public open override fun toDouble(): kotlin.Double
@@ -2121,7 +2121,11 @@ public abstract class Number {
public abstract fun toByte(): kotlin.Byte
public abstract fun toChar(): kotlin.Char
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.
If you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it.
See https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.9")
public open fun toChar(): kotlin.Char
public abstract fun toDouble(): kotlin.Double
@@ -2382,6 +2386,7 @@ public final class Short : kotlin.Number, kotlin.Comparable<kotlin.Short> {
public open override fun toByte(): kotlin.Byte
@kotlin.Deprecated(message = "Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", replaceWith = kotlin.ReplaceWith(expression = "this.toInt().toChar()", imports = {}))
@kotlin.DeprecatedSinceKotlin(errorSince = "2.3", warningSince = "1.5")
public open override fun toChar(): kotlin.Char
public open override fun toDouble(): kotlin.Double
@@ -249,7 +249,7 @@ public class Byte private constructor() : Number(), Comparable<Byte> {
* whereas the most significant 8 bits are filled with the sign bit of this value.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override fun toChar(): Char
/**
* Converts this [Byte] value to [Short].
@@ -542,6 +542,7 @@ public class Short private constructor() : Number(), Comparable<Short> {
* i.e. it has the same binary representation as this `Short`.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override fun toChar(): Char
/** Returns this value. */
public override fun toShort(): Short
@@ -861,6 +862,7 @@ public class Int private constructor() : Number(), Comparable<Int> {
*
* The resulting `Char` code is represented by the least significant 16 bits of this `Int` value.
*/
@Suppress("OVERRIDE_DEPRECATION")
public override fun toChar(): Char
/**
* Converts this [Int] value to [Short].
@@ -1118,7 +1120,7 @@ public class Float private constructor() : Number(), Comparable<Float> {
* The resulting `Char` value is equal to `this.toInt().toChar()`.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override fun toChar(): Char
/**
* Converts this [Float] value to [Short].
@@ -1374,7 +1376,7 @@ public class Double private constructor() : Number(), Comparable<Double> {
* The resulting `Char` value is equal to `this.toInt().toChar()`.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override fun toChar(): Char
/**
* Converts this [Double] value to [Short].
+1 -1
View File
@@ -307,7 +307,7 @@ public class Long internal constructor(
public override fun toByte(): Byte = low.toByte()
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5")
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override fun toChar(): Char = low.toChar()
public override fun toShort(): Short = low.toShort()
public override fun toInt(): Int = low
@@ -313,6 +313,8 @@ public class Byte private constructor(private val value: Byte) : Number(), Compa
* The least significant 8 bits of the resulting `Char` code are the same as the bits of this `Byte` value,
* whereas the most significant 8 bits are filled with the sign bit of this value.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override fun toChar(): Char = reinterpretAsInt().reinterpretAsChar()
/**
@@ -696,6 +698,8 @@ public class Short private constructor(private val value: Short) : Number(), Com
* The resulting `Char` code is equal to this value reinterpreted as an unsigned number,
* i.e. it has the same binary representation as this `Short`.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override fun toChar(): Char = reinterpretAsInt().reinterpretAsChar()
/** Returns this value. */
@@ -1125,6 +1129,7 @@ public class Int private constructor(private val value: Int) : Number(), Compara
*
* The resulting `Char` code is represented by the least significant 16 bits of this `Int` value.
*/
@Suppress("OVERRIDE_DEPRECATION")
public override fun toChar(): Char =
(this and 0xFFFF).reinterpretAsChar()
@@ -1576,6 +1581,8 @@ public class Long private constructor(private val value: Long) : Number(), Compa
*
* The resulting `Char` code is represented by the least significant 16 bits of this `Long` value.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override inline fun toChar(): Char =
this.toInt().toChar()
@@ -1923,6 +1930,8 @@ public class Float private constructor(private val value: Float) : Number(), Com
*
* The resulting `Char` value is equal to `this.toInt().toChar()`.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override inline fun toChar(): Char = this.toInt().toChar()
/**
@@ -2264,6 +2273,8 @@ public class Double private constructor(private val value: Double) : Number(), C
*
* The resulting `Char` value is equal to `this.toInt().toChar()`.
*/
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
public override inline fun toChar(): Char = this.toInt().toChar()
/**