Provide java.util.AbstractCollection and AbstractList as deprecated classes with implemented abstract methods rather than as typealiases to smooth migration.
This comes at price that `ArrayList is java.util.AbstractColleciton` is false.
This commit is contained in:
@@ -34,10 +34,23 @@ public class Date() {
|
||||
|
||||
// TODO: Deprecate with replacement
|
||||
public typealias RandomAccess = kotlin.collections.RandomAccess
|
||||
public typealias AbstractCollection<E> = kotlin.collections.AbstractMutableCollection<E>
|
||||
public typealias AbstractList<E> = kotlin.collections.AbstractMutableList<E>
|
||||
public typealias ArrayList<E> = kotlin.collections.ArrayList<E>
|
||||
public typealias HashSet<E> = kotlin.collections.HashSet<E>
|
||||
public typealias LinkedHashSet<E> = kotlin.collections.LinkedHashSet<E>
|
||||
public typealias HashMap<K, V> = kotlin.collections.HashMap<K, V>
|
||||
public typealias LinkedHashMap<K, V> = kotlin.collections.LinkedHashMap<K, V>
|
||||
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>"))
|
||||
public abstract class AbstractList<E> : kotlin.collections.AbstractMutableList<E>() {
|
||||
override fun add(index: Int, element: E): Unit = throw UnsupportedOperationException()
|
||||
override fun removeAt(index: Int): E = throw UnsupportedOperationException()
|
||||
override fun set(index: Int, element: E): E = throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package foo
|
||||
|
||||
import java.util.AbstractList
|
||||
|
||||
class MyList<T>(vararg val data: T) : AbstractList<T>() {
|
||||
override fun get(index: Int) = data[index]
|
||||
override val size: Int get() = data.size
|
||||
|
||||
Reference in New Issue
Block a user