[JS IR] Make Char a value class (again)

#KT-35100 Fixed
This commit is contained in:
Sergej Jaskiewicz
2021-12-01 16:22:09 +03:00
committed by Space
parent 599f705842
commit 67dfe7bed1
19 changed files with 226 additions and 51 deletions
+1 -1
View File
@@ -1064,7 +1064,7 @@ public final class ByteArray {
public final operator fun set(index: kotlin.Int, value: kotlin.Byte): kotlin.Unit
}
public final class Char : kotlin.Comparable<kotlin.Char> {
/*∆*/ public final class Char : kotlin.Comparable<kotlin.Char> {
public open override operator fun compareTo(other: kotlin.Char): kotlin.Int
public final operator fun dec(): kotlin.Char
+1 -1
View File
@@ -1032,7 +1032,7 @@ public final class ByteArray {
public final operator fun set(index: kotlin.Int, value: kotlin.Byte): kotlin.Unit
}
public final class Char : kotlin.Comparable<kotlin.Char> {
/*∆*/ public final inline class Char : kotlin.Comparable<kotlin.Char> {
/*∆*/ @kotlin.SinceKotlin(version = "1.5")
/*∆*/ @kotlin.WasExperimental(markerClass = {kotlin.ExperimentalStdlibApi::class})
/*∆*/ public constructor Char(code: kotlin.UShort)
+7 -17
View File
@@ -9,13 +9,13 @@ package kotlin
* Represents a 16-bit Unicode character.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `char`.
*/
// TODO: KT-35100
//public inline class Char internal constructor (val value: Int) : Comparable<Char> {
public class Char
@SinceKotlin("1.5")
@WasExperimental(ExperimentalStdlibApi::class)
constructor(code: UShort) : Comparable<Char> {
private val value: Int = code.toInt()
public value class Char
@kotlin.internal.LowPriorityInOverloadResolution
internal constructor(private val value: Int) : Comparable<Char> {
@SinceKotlin("1.5")
@WasExperimental(ExperimentalStdlibApi::class)
public constructor(code: UShort) : this(code.toInt())
/**
* Compares this value with the specified value for order.
@@ -76,16 +76,6 @@ constructor(code: UShort) : Comparable<Char> {
@DeprecatedSinceKotlin(warningSince = "1.5")
public fun toDouble(): Double = value.toDouble()
override fun equals(other: Any?): Boolean {
@Suppress("IMPLICIT_BOXING_IN_IDENTITY_EQUALS")
if (other === this) return true
if (other !is Char) return false
return this.value == other.value
}
override fun hashCode(): Int = value
// TODO implicit usages of toString and valueOf must be covered in DCE
@Suppress("JS_NAME_PROHIBITED_FOR_OVERRIDE")
@JsName("toString")
+1 -2
View File
@@ -34,8 +34,7 @@ internal fun booleanArray(size: Int): BooleanArray = withType("BooleanArray", fi
internal fun booleanArrayOf(arr: Array<Boolean>): BooleanArray = withType("BooleanArray", arr.asDynamic().slice()).unsafeCast<BooleanArray>()
//internal fun charArray(size: Int): CharArray = withType("CharArray", fillArrayVal(Array<Int>(size), 0)).unsafeCast<CharArray>()
internal fun charArray(size: Int): CharArray = withType("CharArray", fillArrayVal(Array<Char>(size), Char(0))).unsafeCast<CharArray>()
internal fun charArray(size: Int): CharArray = withType("CharArray", fillArrayVal(Array<Int>(size), 0)).unsafeCast<CharArray>()
internal fun charArrayOf(arr: Array<Char>): CharArray = withType("CharArray", arr.asDynamic().slice()).unsafeCast<CharArray>()