Support cast to array with reified argument in interpreter

This commit is contained in:
Ivan Kylchik
2021-06-10 18:20:35 +03:00
committed by TeamCityServer
parent cc56acc2c2
commit b10fdb919f
2 changed files with 25 additions and 5 deletions
+6
View File
@@ -10,6 +10,8 @@ inline fun <reified T> bar(): String {
return if (listOf<Int>() as? T == null) "Can't cast" else "Safe cast"
}
inline fun <reified T> arrayCast(vararg t: T): Array<T> = t as Array<T>
const val a1 = <!EVALUATED: `Safe cast`!>foo<Int>()<!>
const val a2 = <!EVALUATED: `Safe cast`!>foo<Int?>()<!>
const val a3 = <!EVALUATED: `Safe cast`!>foo<Double?>()<!>
@@ -31,3 +33,7 @@ const val c5 = <!EVALUATED: `true`!>arrayOf<List<Int>>(listOf(1, 2), listOf(2, 3
const val c6 = <!EVALUATED: `false`!>arrayOf<List<Int>>(listOf(1, 2), listOf(2, 3)) as? Array<Collection<String>> == null<!>
const val c7 = <!EVALUATED: `false`!>Array<List<Int>>(3) { listOf(it, it + 1) } as? Array<List<String>?> == null<!>
const val c8 = <!EVALUATED: `true`!>Array<List<Int>>(3) { listOf(it, it + 1) } as? Array<Set<Int>> == null<!>
const val d1 = arrayCast(arrayOf<Int>(1, 2, 3)).<!EVALUATED: `1`!>size<!>
const val d2 = arrayCast(*arrayOf<Int>(1, 2, 3)).<!EVALUATED: `3`!>size<!>
const val d3 = arrayCast<Int>(1, 2, 3).<!EVALUATED: `3`!>size<!>