Remove overrides of equals and hashCode from AbstractCollection and AbstractMap.values, making the equality referential again.

This commit is contained in:
Ilya Gorbunov
2016-09-27 21:47:41 +03:00
parent 976260bda6
commit 282629f618
4 changed files with 0 additions and 18 deletions
-3
View File
@@ -43,9 +43,6 @@ public typealias LinkedHashMap<K, V> = kotlin.collections.LinkedHashMap<K, V>
@Deprecated("Use AbstractCollection or AbstractMutableCollection from kotlin.collections", ReplaceWith("kotlin.collections.AbstractMutableCollection<E>"))
public abstract class AbstractCollection<E> : kotlin.collections.AbstractMutableCollection<E>() {
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<E>"))
@@ -26,10 +26,6 @@ public abstract class AbstractCollection<out E> 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()
}
@@ -103,15 +103,6 @@ public abstract class AbstractMap<K, out V> protected constructor() : Map<K, V>
}
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!!
@@ -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