Use empty array instead of presized for Collection.toArray

#KT-21918
This commit is contained in:
Ilya Gorbunov
2017-12-21 06:06:26 +03:00
parent 8203d1c3fe
commit 94a0e508d9
@@ -47,7 +47,7 @@ public inline fun ByteArray.toString(charset: Charset): String = String(this, ch
public inline fun <reified T> Collection<T>.toTypedArray(): Array<T> {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
val thisCollection = this as java.util.Collection<T>
return thisCollection.toArray(arrayOfNulls<T>(thisCollection.size())) as Array<T>
return thisCollection.toArray(arrayOfNulls<T>(0)) as Array<T>
}
/** Internal unsafe construction of array based on reference array type */