Relax generic variance in Array.flatten

This commit is contained in:
Ilya Gorbunov
2016-10-24 15:26:02 +03:00
parent adaad58cc7
commit 49ea0f5984
2 changed files with 14 additions and 1 deletions
@@ -30,7 +30,7 @@ public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: ar
/**
* Returns a single list of all elements from all arrays in the given array.
*/
public fun <T> Array<Array<out T>>.flatten(): List<T> {
public fun <T> Array<out Array<out T>>.flatten(): List<T> {
val result = ArrayList<T>(sumBy { it.size })
for (element in this) {
result.addAll(element)