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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user