Ensure vararg copy behavior for specific case of arrayListOf in JS.
This commit is contained in:
@@ -16,13 +16,18 @@
|
||||
|
||||
package java.util
|
||||
|
||||
public fun HashSet<E>(c: Collection<E>): HashSet<E> = HashSet<E>(c.size()).apply { addAll(c) }
|
||||
public fun HashSet<E>(c: Collection<E>): HashSet<E>
|
||||
= HashSet<E>(c.size()).apply { addAll(c) }
|
||||
|
||||
public fun LinkedHashSet<E>(c: Collection<E>): HashSet<E> = LinkedHashSet<E>(c.size()).apply { addAll(c) }
|
||||
public fun LinkedHashSet<E>(c: Collection<E>): HashSet<E>
|
||||
= LinkedHashSet<E>(c.size()).apply { addAll(c) }
|
||||
|
||||
public fun HashMap<K, V>(m: Map<K, V>): HashMap<K, V> = HashMap<K, V>(m.size()).apply { putAll(m) }
|
||||
public fun HashMap<K, V>(m: Map<K, V>): HashMap<K, V>
|
||||
= HashMap<K, V>(m.size()).apply { putAll(m) }
|
||||
|
||||
public fun LinkedHashMap<K, V>(m: Map<K, V>): LinkedHashMap<K, V> = LinkedHashMap<K, V>(m.size()).apply { putAll(m) }
|
||||
public fun LinkedHashMap<K, V>(m: Map<K, V>): LinkedHashMap<K, V>
|
||||
= LinkedHashMap<K, V>(m.size()).apply { putAll(m) }
|
||||
|
||||
public fun ArrayList<E>(c: Collection<E>): ArrayList<E> = ArrayList<E>().apply { asDynamic().array = c.toTypedArray<Any?>() } // black dynamic magic
|
||||
public fun ArrayList<E>(c: Collection<E>): ArrayList<E>
|
||||
= ArrayList<E>().apply { asDynamic().array = c.toTypedArray<Any?>() } // black dynamic magic
|
||||
|
||||
|
||||
@@ -91,3 +91,7 @@ internal fun <T> arrayPlusCollection(array: dynamic, collection: Collection<T>):
|
||||
for (element in collection) result[index++] = element
|
||||
return result
|
||||
}
|
||||
|
||||
// copies vararg array due to different spread vararg behavior in JS.
|
||||
// After fixing #KT-6491 may return `this`
|
||||
internal inline fun <T> Array<out T>.varargToArrayOfAny(): Array<out Any?> = this.copyOf()
|
||||
|
||||
Reference in New Issue
Block a user