Do not leak primitiveness of an array wrapped with asList

A primitive array wrapped in a List with asList had incorrect implementation of toArray method:
while it declares that an object array is returned, it returned a primitive array.
Therefore the methods such as `Collection.toTypedArray()` and its dependents
`ArrayList(collection)`, `Collection + Iterable` might behave incorrectly
having relied on `toTypedArray` returned an object array.

#KT-21828 Fixed
This commit is contained in:
Ilya Gorbunov
2017-12-15 19:26:17 +03:00
parent c55f08a166
commit d8cd926a8c
2 changed files with 8 additions and 1 deletions
@@ -117,7 +117,7 @@ public open class ArrayList<E> internal constructor(private var array: Array<Any
override fun lastIndexOf(element: E): Int = array.lastIndexOf(element)
override fun toString() = arrayToString(array)
override fun toArray(): Array<Any?> = array.copyOf()
override fun toArray(): Array<Any?> = js("[]").slice.call(array)
private fun rangeCheck(index: Int) = index.apply {