Provide protected toArray implementation in AbstractCollection.

Relates to #KT-13898
This commit is contained in:
Ilya Gorbunov
2016-12-24 04:28:32 +03:00
parent bbf61664ea
commit cdfb72ab76
8 changed files with 71 additions and 11 deletions

View File

@@ -8,10 +8,10 @@ open class SingletonCollection<T>(val value: T) : AbstractCollection<T>() {
override val size = 1
override fun iterator(): Iterator<T> = listOf(value).iterator()
protected open fun toArray(): Array<Any?> =
protected override fun toArray(): Array<Any?> =
arrayOf<Any?>(value)
protected open fun <E> toArray(a: Array<E>): Array<E> {
protected override fun <E> toArray(a: Array<E>): Array<E> {
a[0] = value as E
return a
}