From 97e86fb2ce18661d33dbaa685d94e06801cc6102 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Tue, 21 Jan 2020 15:51:48 +0300 Subject: [PATCH] [stdlib-js-ir] Char shouldn't be a data class --- libraries/stdlib/js-ir/builtins/Char.kt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libraries/stdlib/js-ir/builtins/Char.kt b/libraries/stdlib/js-ir/builtins/Char.kt index 7defee2f666..850918dd42f 100644 --- a/libraries/stdlib/js-ir/builtins/Char.kt +++ b/libraries/stdlib/js-ir/builtins/Char.kt @@ -12,7 +12,7 @@ package kotlin // TODO: KT-35100 //@Suppress("NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS") //public inline class Char internal constructor (val value: Int) : Comparable { -public data class Char internal constructor(val value: Int) : Comparable { +public class Char internal constructor(val value: Int) : Comparable { /** * Compares this value with the specified value for order. @@ -52,6 +52,15 @@ public data class Char internal constructor(val value: Int) : Comparable { /** Returns the value of this character as a `Double`. */ public fun toDouble(): Double = value.toDouble() + override fun equals(other: Any?): Boolean { + 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")