From 282629f618a61f20e1c5f53066b171a87b21b09f Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 27 Sep 2016 21:47:41 +0300 Subject: [PATCH] Remove overrides of equals and hashCode from AbstractCollection and AbstractMap.values, making the equality referential again. --- js/js.libraries/src/core/javautil.kt | 3 --- .../stdlib/src/kotlin/collections/AbstractCollection.kt | 4 ---- libraries/stdlib/src/kotlin/collections/AbstractMap.kt | 9 --------- .../reference-public-api/kotlin-stdlib.txt | 2 -- 4 files changed, 18 deletions(-) diff --git a/js/js.libraries/src/core/javautil.kt b/js/js.libraries/src/core/javautil.kt index 1a35985dfda..acb9b1bb453 100644 --- a/js/js.libraries/src/core/javautil.kt +++ b/js/js.libraries/src/core/javautil.kt @@ -43,9 +43,6 @@ public typealias LinkedHashMap = kotlin.collections.LinkedHashMap @Deprecated("Use AbstractCollection or AbstractMutableCollection from kotlin.collections", ReplaceWith("kotlin.collections.AbstractMutableCollection")) public abstract class AbstractCollection : kotlin.collections.AbstractMutableCollection() { override fun add(element: E): Boolean = throw UnsupportedOperationException() - override fun equals(other: Any?): Boolean = this === other - private val hashCode_ by lazy { (Math.random() * ((1 shl 31) - 1)).toInt() } - override fun hashCode(): Int = hashCode_ } @Deprecated("Use AbstractList or AbstractMutableList from kotlin.collections", ReplaceWith("kotlin.collections.AbstractMutableList")) diff --git a/libraries/stdlib/src/kotlin/collections/AbstractCollection.kt b/libraries/stdlib/src/kotlin/collections/AbstractCollection.kt index e23d3e383c9..4175a7f517a 100644 --- a/libraries/stdlib/src/kotlin/collections/AbstractCollection.kt +++ b/libraries/stdlib/src/kotlin/collections/AbstractCollection.kt @@ -26,10 +26,6 @@ public abstract class AbstractCollection protected constructor() : Collec override fun isEmpty(): Boolean = size == 0 - abstract override fun hashCode(): Int - - abstract override fun equals(other: Any?): Boolean - override fun toString(): String = joinToString(", ", "[", "]") { if (it === this) "(this Collection)" else it.toString() } diff --git a/libraries/stdlib/src/kotlin/collections/AbstractMap.kt b/libraries/stdlib/src/kotlin/collections/AbstractMap.kt index 3dda4f2919f..a1297d4e790 100644 --- a/libraries/stdlib/src/kotlin/collections/AbstractMap.kt +++ b/libraries/stdlib/src/kotlin/collections/AbstractMap.kt @@ -103,15 +103,6 @@ public abstract class AbstractMap protected constructor() : Map } override val size: Int get() = this@AbstractMap.size - - // TODO: should we implement them this way? Currently it's unspecified in JVM - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is Collection<*>) return false - return AbstractList.orderedEquals(this, other) - } - - override fun hashCode(): Int = AbstractList.orderedHashCode(this) } } return _values!! diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib.txt index b9faee8202b..77aed380be5 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib.txt @@ -73,9 +73,7 @@ public abstract class kotlin/collections/AbstractCollection : java/util/Collecti public fun clear ()V public fun contains (Ljava/lang/Object;)Z public fun containsAll (Ljava/util/Collection;)Z - public abstract fun equals (Ljava/lang/Object;)Z public abstract fun getSize ()I - public abstract fun hashCode ()I public fun isEmpty ()Z public abstract fun iterator ()Ljava/util/Iterator; public fun remove (Ljava/lang/Object;)Z