[JS IR] Make Char a value class (again)
#KT-35100 Fixed
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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>()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user