[Stdlib] Deprecate and make open Number.toChar()
^KT-46465 Fixed
This commit is contained in:
committed by
Space Team
parent
90ec84d7b7
commit
a64d8e8a31
@@ -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()
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user