Primitive array constructor-like functions with init lambda.

#KT-8831

Update testData and resolve ambiguity in newArray test
This commit is contained in:
Ilya Gorbunov
2015-12-18 02:05:04 +03:00
parent 513c4a4562
commit 03816373b3
7 changed files with 524 additions and 16 deletions
+8
View File
@@ -1,6 +1,14 @@
package-fragment kotlin
public inline fun </*0*/ reified T> Array(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, T>): kotlin.Array<T>
public inline fun BooleanArray(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, kotlin.Boolean>): kotlin.BooleanArray
public inline fun ByteArray(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, kotlin.Byte>): kotlin.ByteArray
public inline fun CharArray(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, kotlin.Char>): kotlin.CharArray
public inline fun DoubleArray(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, kotlin.Double>): kotlin.DoubleArray
public inline fun FloatArray(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, kotlin.Float>): kotlin.FloatArray
public inline fun IntArray(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, kotlin.Int>): kotlin.IntArray
public inline fun LongArray(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, kotlin.Long>): kotlin.LongArray
public inline fun ShortArray(/*0*/ size: kotlin.Int, /*1*/ init: kotlin.Function1<kotlin.Int, kotlin.Short>): kotlin.ShortArray
public inline fun </*0*/ reified T> arrayOf(/*0*/ vararg elements: T /*kotlin.Array<out T>*/): kotlin.Array<T>
public fun </*0*/ reified T> arrayOfNulls(/*0*/ size: kotlin.Int): kotlin.Array<T?>
public fun booleanArrayOf(/*0*/ vararg elements: kotlin.Boolean /*kotlin.BooleanArray*/): kotlin.BooleanArray
@@ -1,11 +1,13 @@
private fun <T> upcast(value: T): T = value
fun box(): String {
(::ByteArray)(10)
(::IntArray)(10)
(::ShortArray)(10)
(::LongArray)(10)
(::DoubleArray)(10)
(::FloatArray)(10)
(::BooleanArray)(10)
upcast<(Int)->ByteArray>(::ByteArray)(10)
upcast<(Int)->IntArray>(::IntArray)(10)
upcast<(Int)->ShortArray>(::ShortArray)(10)
upcast<(Int)->LongArray>(::LongArray)(10)
upcast<(Int)->DoubleArray>(::DoubleArray)(10)
upcast<(Int)->FloatArray>(::FloatArray)(10)
upcast<(Int)->BooleanArray>(::BooleanArray)(10)
return "OK"
}