[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
@@ -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