[JS IR] Don't mark Char as a value class
Char will still be treated as a value class (see JsInlineClassesUtils.kt)
This commit is contained in:
+5
-3
@@ -1,14 +1,16 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1372
|
||||
package foo
|
||||
|
||||
class A
|
||||
|
||||
fun box(): String {
|
||||
|
||||
assertEquals(true, 'A' == 'A')
|
||||
assertEquals(false, 'A'== 'B')
|
||||
assertEquals(false, 'A' == 'B')
|
||||
assertEquals(false, ('A' as Any) == (65 as Any))
|
||||
|
||||
// FIXME(KT-50157): assertEquals(true, 'A' === 'A')
|
||||
assertEquals(false, 'A' === 'B')
|
||||
assertEquals(false, ('A' as Any) === (65 as Any))
|
||||
|
||||
assertTrue(bar('Q'))
|
||||
assertFalse(bar('W'))
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -3231,4 +3231,4 @@ public final annotation class UseExperimental : kotlin.Annotation {
|
||||
public constructor UseExperimental(vararg markerClass: kotlin.reflect.KClass<out kotlin.Annotation>)
|
||||
|
||||
public final val markerClass: kotlin.Array<out kotlin.reflect.KClass<out kotlin.Annotation>> { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1032,7 +1032,7 @@ public final class ByteArray {
|
||||
public final operator fun set(index: kotlin.Int, value: kotlin.Byte): kotlin.Unit
|
||||
}
|
||||
|
||||
/*∆*/ public final inline class Char : kotlin.Comparable<kotlin.Char> {
|
||||
public final class Char : kotlin.Comparable<kotlin.Char> {
|
||||
/*∆*/ @kotlin.SinceKotlin(version = "1.5")
|
||||
/*∆*/ @kotlin.WasExperimental(markerClass = {kotlin.ExperimentalStdlibApi::class})
|
||||
/*∆*/ public constructor Char(code: kotlin.UShort)
|
||||
@@ -3231,4 +3231,4 @@ public final annotation class UseExperimental : kotlin.Annotation {
|
||||
public constructor UseExperimental(vararg markerClass: kotlin.reflect.KClass<out kotlin.Annotation>)
|
||||
|
||||
public final val markerClass: kotlin.Array<out kotlin.reflect.KClass<out kotlin.Annotation>> { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,15 @@
|
||||
|
||||
package kotlin
|
||||
|
||||
// Char is a magic class.
|
||||
// Char is defined as a regular class, but we lower it as a value class.
|
||||
// See [org.jetbrains.kotlin.ir.backend.js.utils.JsInlineClassesUtils.isClassInlineLike] for explanation.
|
||||
|
||||
/**
|
||||
* Represents a 16-bit Unicode character.
|
||||
* On the JVM, non-nullable values of this type are represented as values of the primitive type `char`.
|
||||
*/
|
||||
public value class Char
|
||||
public /*value*/ class Char
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
internal constructor(private val value: Int) : Comparable<Char> {
|
||||
|
||||
@@ -76,6 +80,13 @@ internal constructor(private val value: Int) : Comparable<Char> {
|
||||
@DeprecatedSinceKotlin(warningSince = "1.5")
|
||||
public fun toDouble(): Double = value.toDouble()
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
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")
|
||||
@@ -139,4 +150,4 @@ internal constructor(private val value: Int) : Comparable<Char> {
|
||||
public const val SIZE_BITS: Int = 16
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user