Introduce unsafeCast function. Provide more JS-idiomatic emptyArray() implementation.

#KT-14034 Fixed
This commit is contained in:
Ilya Gorbunov
2016-11-17 20:02:15 +03:00
parent 18d50b930d
commit 87c9d4e84e
6 changed files with 33 additions and 28 deletions
@@ -27,12 +27,12 @@ fun specialJS(): List<GenericFunction> {
returns("List<T>")
body(ArraysOfObjects) {
"""
return ArrayList<T>(this as Array<Any?>)
return ArrayList<T>(this.unsafeCast<Array<Any?>>())
"""
}
inline(true, ArraysOfPrimitives)
body(ArraysOfPrimitives) {"""return (this as Array<T>).asList()"""}
body(ArraysOfPrimitives) {"""return this.unsafeCast<Array<T>>().asList()"""}
}
@@ -46,7 +46,7 @@ fun specialJS(): List<GenericFunction> {
}
body {
"""
return copyOf() as Array<T>
return copyOf().unsafeCast<Array<T>>()
"""
}
}