[FIR2IR] Approximate non-denotable types when converting ConeType to IrType

This commit is contained in:
Dmitriy Novozhilov
2021-02-27 15:19:23 +03:00
committed by TeamCityServer
parent c271f953d7
commit da0fd7cc15
31 changed files with 147 additions and 325 deletions
@@ -0,0 +1,25 @@
// TARGET_BACKEND: JVM
// WITH_STDLIB
// WITH_REFLECT
import kotlin.reflect.KType
import kotlin.reflect.full.starProjectedType
fun convertPrimitivesArray(type: KType, args: Sequence<String?>): Any? {
val a = when (type.classifier) {
IntArray::class -> args.map { it?.toIntOrNull() }
CharArray::class -> args.map { it?.singleOrNull() }
else -> null
}
val b = a?.toList()
val c = b?.takeUnless { null in it }
val d = c?.toTypedArray()
return d
}
fun box(): String {
val type = CharArray::class.starProjectedType
val sequence = sequenceOf("O", "K")
val array = convertPrimitivesArray(type, sequence) as Array<*>
return array.joinToString("") { it.toString() }
}