Implement toTypedArray as non-intrinsic.

Remove unused intrinsic method.
This commit is contained in:
Ilya Gorbunov
2015-04-22 18:54:54 +03:00
parent c3f825a711
commit 526348b207
3 changed files with 4 additions and 42 deletions
@@ -82,8 +82,10 @@ public fun ByteArray.toString(charset: Charset): String = String(this, charset)
* Allocates an array of runtime type `T` having its size equal to the size of this collection
* and populates the array with the elements of this collection.
*/
[Intrinsic("kotlin.collections.copyToArray")] public fun <reified T> Collection<T>.toTypedArray(): Array<T> =
throw UnsupportedOperationException()
public inline fun <reified T> Collection<T>.toTypedArray(): Array<T> {
val thisCollection = this as java.util.Collection<T>
return thisCollection.toArray(arrayOfNulls<T>(thisCollection.size())) as Array<T>
}
/** Returns the array if it's not null, or an empty array otherwise. */
public inline fun <reified T> Array<out T>?.orEmpty(): Array<out T> = this ?: arrayOf<T>()