KT-15574 Can't instantiate Array through Type Alias

Array instatiation code should handle type alias constructors properly.

So far, we don't have constructors with type parameters
different from the type parameters of the resulting type,
so we can safely take type arguments of the underlying type.
This commit is contained in:
Dmitry Petrov
2017-02-01 12:27:42 +03:00
parent f5a431490c
commit 7600f89f0b
9 changed files with 120 additions and 1 deletions
@@ -0,0 +1,8 @@
class Pair<T1, T2>(val x1: T1, val x2: T2)
typealias ST<T> = Pair<String, T>
fun box(): String {
val st = ST<String>("O", "K")
return st.x1 + st.x2
}
@@ -0,0 +1,16 @@
typealias BoolArray = Array<Boolean>
typealias IArray = IntArray
typealias MyArray<T> = Array<T>
fun box(): String {
val ba = BoolArray(1) { true }
if (!ba[0]) return "Fail #1"
val ia = IArray(1) { 42 }
if (ia[0] != 42) return "Fail #2"
val ma = MyArray<Int>(1) { 42 }
if (ma[0] != 42) return "Fail #2"
return "OK"
}