Deprecate Char-to-Number conversions in stdlib (JVM and JS)

- Int.toChar was left non-deprecated because the replacement is not intrinsic yet.
- Number.toChar was left non-deprecated because otherwise the deprecation propagates to the override, Int.toChar.

KT-23451
This commit is contained in:
Ilya Gorbunov
2021-04-06 15:36:44 +03:00
parent b976cd812a
commit b64b96eee6
59 changed files with 273 additions and 169 deletions
+10 -2
View File
@@ -42,12 +42,20 @@ class GenerateProgressions(out: PrintWriter) : BuiltInsSourceGenerator(out) {
val hashCode = "=\n" + when (kind) {
CHAR ->
" if (isEmpty()) -1 else (31 * (31 * first.toInt() + last.toInt()) + step)"
" if (isEmpty()) -1 else (31 * (31 * first.code + last.code) + step)"
INT ->
" if (isEmpty()) -1 else (31 * (31 * first + last) + step)"
LONG ->
" if (isEmpty()) -1 else (31 * (31 * ${hashLong("first")} + ${hashLong("last")}) + ${hashLong("step")}).toInt()"
}
val elementToIncrement = when (kind) {
CHAR -> ".code"
else -> ""
}
val incrementToElement = when (kind) {
CHAR -> ".toChar()"
else -> ""
}
out.println(
"""/**
@@ -73,7 +81,7 @@ public open class $progression
/**
* The last element in the progression.
*/
public val last: $t = getProgressionLastElement(start.to$incrementType(), endInclusive.to$incrementType(), step).to$t()
public val last: $t = getProgressionLastElement(start$elementToIncrement, endInclusive$elementToIncrement, step)$incrementToElement
/**
* The step of the progression.