Migrate deprecations in core, compiler, idea, tests
Replacing deprecated Char.toInt() with Char.code and Number.toChar() with Number.toInt().toChar(), where Number is not Int. KT-23451
This commit is contained in:
+1
-1
@@ -243,7 +243,7 @@ abstract class AbstractAnnotationDeserializer(
|
||||
const(kind, value.intValue)
|
||||
}
|
||||
|
||||
CHAR -> const(ConstantValueKind.Char, value.intValue.toChar())
|
||||
CHAR -> const(ConstantValueKind.Char, value.intValue.toInt().toChar())
|
||||
FLOAT -> const(ConstantValueKind.Float, value.floatValue)
|
||||
DOUBLE -> const(ConstantValueKind.Double, value.doubleValue)
|
||||
BOOLEAN -> const(ConstantValueKind.Boolean, (value.intValue != 0L))
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ class FirConstDeserializer(
|
||||
): FirExpression? {
|
||||
return when (constKind) {
|
||||
"BYTE", "B" -> buildConstExpression(null, ConstantValueKind.Byte, ((protoValue?.intValue ?: sourceValue) as Number).toByte())
|
||||
"CHAR", "C" -> buildConstExpression(null, ConstantValueKind.Char, ((protoValue?.intValue ?: sourceValue) as Number).toChar())
|
||||
"CHAR", "C" -> buildConstExpression(null, ConstantValueKind.Char, ((protoValue?.intValue ?: sourceValue) as Number).toInt().toChar())
|
||||
"SHORT", "S" -> buildConstExpression(null, ConstantValueKind.Short, ((protoValue?.intValue ?: sourceValue) as Number).toShort())
|
||||
"INT", "I" -> buildConstExpression(null, ConstantValueKind.Int, protoValue?.intValue?.toInt() ?: sourceValue as Int)
|
||||
"LONG", "J" -> buildConstExpression(null, ConstantValueKind.Long, protoValue?.intValue ?: sourceValue as Long)
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ internal object FirAnnotationArgumentVisitor : AnnotationArgumentVisitor<Unit, F
|
||||
|
||||
override fun visitCharValue(value: CharValue, data: FirAnnotationArgumentVisitorData) {
|
||||
data.builder.type = ProtoBuf.Annotation.Argument.Value.Type.CHAR
|
||||
data.builder.intValue = value.value.toLong()
|
||||
data.builder.intValue = value.value.code.toLong()
|
||||
}
|
||||
|
||||
override fun visitDoubleValue(value: DoubleValue, data: FirAnnotationArgumentVisitorData) {
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ internal class ByteValue(value: Byte) : IntegerValueConstant<Byte>(value) {
|
||||
internal class CharValue(value: Char) : IntegerValueConstant<Char>(value) {
|
||||
override fun <R, D> accept(visitor: AnnotationArgumentVisitor<R, D>, data: D): R = visitor.visitCharValue(this, data)
|
||||
|
||||
override fun toString(): String = "\\u%04X ('%s')".format(value.toInt(), getPrintablePart(value))
|
||||
override fun toString(): String = "\\u%04X ('%s')".format(value.code, getPrintablePart(value))
|
||||
|
||||
private fun getPrintablePart(c: Char): String = when (c) {
|
||||
'\b' -> "\\b"
|
||||
|
||||
@@ -847,10 +847,10 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
||||
if (value !is Char) {
|
||||
print(value.toString())
|
||||
} else {
|
||||
if (value.toInt() in 32..127) {
|
||||
if (value.code in 32..127) {
|
||||
print(value)
|
||||
} else {
|
||||
print(value.toInt())
|
||||
print(value.code)
|
||||
}
|
||||
}
|
||||
print(")")
|
||||
|
||||
Reference in New Issue
Block a user