From adfb296e4563fa6243e8904ba5a717723e8ad234 Mon Sep 17 00:00:00 2001 From: Zalim Bashorov Date: Thu, 28 Nov 2019 18:51:41 +0300 Subject: [PATCH] [stdlib-js-ir] Add equals, hashCode, toString to some builtins Namely: * Throwable; * primitive numbers except Long (which implemented in Kotlin). --- libraries/stdlib/js-ir/builtins/Primitives.kt | 20 +++++++++++++++++++ libraries/stdlib/js-ir/builtins/Throwable.kt | 19 +++++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/libraries/stdlib/js-ir/builtins/Primitives.kt b/libraries/stdlib/js-ir/builtins/Primitives.kt index 5904e6393fa..34356b6e022 100644 --- a/libraries/stdlib/js-ir/builtins/Primitives.kt +++ b/libraries/stdlib/js-ir/builtins/Primitives.kt @@ -218,6 +218,10 @@ public class Byte private constructor() : Number(), Comparable { * The resulting `Double` value represents the same numerical value as this `Byte`. */ public override fun toDouble(): Double + + public override fun equals(other: Any?): Boolean + public override fun hashCode(): Int + public override fun toString(): String } /** @@ -428,6 +432,10 @@ public class Short private constructor() : Number(), Comparable { * The resulting `Double` value represents the same numerical value as this `Short`. */ public override fun toDouble(): Double + + public override fun equals(other: Any?): Boolean + public override fun hashCode(): Int + public override fun toString(): String } /** @@ -657,6 +665,10 @@ public class Int private constructor() : Number(), Comparable { * The resulting `Double` value represents the same numerical value as this `Int`. */ public override fun toDouble(): Double + + public override fun equals(other: Any?): Boolean + public override fun hashCode(): Int + public override fun toString(): String } /** @@ -863,6 +875,10 @@ public class Float private constructor() : Number(), Comparable { * The resulting `Double` value represents the same numerical value as this `Float`. */ public override fun toDouble(): Double + + public override fun equals(other: Any?): Boolean + public override fun hashCode(): Int + public override fun toString(): String } /** @@ -1071,5 +1087,9 @@ public class Double private constructor() : Number(), Comparable { public override fun toFloat(): Float /** Returns this value. */ public override fun toDouble(): Double + + public override fun equals(other: Any?): Boolean + public override fun hashCode(): Int + public override fun toString(): String } diff --git a/libraries/stdlib/js-ir/builtins/Throwable.kt b/libraries/stdlib/js-ir/builtins/Throwable.kt index 83fdc12aedf..88f67a839ff 100644 --- a/libraries/stdlib/js-ir/builtins/Throwable.kt +++ b/libraries/stdlib/js-ir/builtins/Throwable.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ @@ -13,11 +13,16 @@ package kotlin */ @JsName("Error") public external open class Throwable { - open val message: String? - open val cause: Throwable? + public open val message: String? + public open val cause: Throwable? - constructor(message: String?, cause: Throwable?) - constructor(message: String?) - constructor(cause: Throwable?) - constructor() + public constructor(message: String?, cause: Throwable?) + public constructor(message: String?) + public constructor(cause: Throwable?) + public constructor() + + // TODO: add specialized version to runtime +// public override fun equals(other: Any?): Boolean +// public override fun hashCode(): Int + public override fun toString(): String } \ No newline at end of file