Generated default implementations for Collection.toArray().

#KT-3352 in progress
This commit is contained in:
Evgeny Gerashchenko
2013-09-26 17:46:30 +04:00
parent d56c59d9d7
commit 41d1f277dc
5 changed files with 194 additions and 1 deletions
@@ -0,0 +1,21 @@
import java.util.Arrays
class MyCollection<T>(val delegate: Collection<T>): Collection<T> by delegate
fun box(): String {
val collection = MyCollection(Arrays.asList(2, 3, 9)) as java.util.Collection<*>
val array1 = collection.toArray()
val array2 = collection.toArray(Array<Int>(3, { 0 }))
if (array1 !is Array<Any>) return (array1 as Object).getClass().toString()
if (array2 !is Array<Int>) return (array2 as Object).getClass().toString()
val s1 = Arrays.toString(array1)
val s2 = Arrays.toString(array2)
if (s1 != "[2, 3, 9]") return "s1 = $s1"
if (s2 != "[2, 3, 9]") return "s2 = $s2"
return "OK"
}