[Stdlib] Deprecate and make open Number.toChar()
^KT-46465 Fixed
This commit is contained in:
committed by
Space Team
parent
90ec84d7b7
commit
a64d8e8a31
@@ -43,8 +43,11 @@ public abstract class Number {
|
||||
/**
|
||||
* Returns the [Char] with the numeric value equal to this number, truncated to 16 bits if appropriate.
|
||||
*/
|
||||
// @Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.", ReplaceWith("this.toInt().toChar()"))
|
||||
public abstract fun toChar(): Char
|
||||
@Deprecated("Direct conversion to Char is deprecated. Use toInt().toChar() or Char constructor instead.\nIf you override toChar() function in your Number inheritor, it's recommended to gradually deprecate the overriding function and then remove it.\nSee https://youtrack.jetbrains.com/issue/KT-46465 for details about the migration", ReplaceWith("this.toInt().toChar()"))
|
||||
@DeprecatedSinceKotlin(warningSince = "1.9", errorSince = "2.3")
|
||||
public open fun toChar(): Char {
|
||||
return toInt().toChar()
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value of this number as a [Short], which may involve rounding or truncation.
|
||||
|
||||
@@ -287,7 +287,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")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun toChar(): Char
|
||||
/**
|
||||
@@ -627,7 +627,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")
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun toChar(): Char
|
||||
/** Returns this value. */
|
||||
@@ -1001,6 +1001,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")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun toChar(): Char
|
||||
/**
|
||||
@@ -1377,7 +1378,7 @@ public class Long private constructor() : Number(), Comparable<Long> {
|
||||
* 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")
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5", errorSince = "2.3")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun toChar(): Char
|
||||
/**
|
||||
@@ -1683,7 +1684,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")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun toChar(): Char
|
||||
/**
|
||||
@@ -1985,7 +1986,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")
|
||||
@kotlin.internal.IntrinsicConstEvaluation
|
||||
public override fun toChar(): Char
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user