Parcelize, JVM IR: Handle star projected and nullable arrays.

This commit is contained in:
Steven Schäfer
2020-10-06 11:31:01 +02:00
committed by Alexander Udalov
parent a6d5c02d9b
commit 714d17ac63
6 changed files with 92 additions and 4 deletions
@@ -50,9 +50,16 @@ val IrType.isBoxedArray: Boolean
get() = classOrNull?.owner?.fqNameWhenAvailable == StandardNames.FqNames.array.toSafe()
fun IrType.getArrayElementType(irBuiltIns: IrBuiltIns): IrType =
if (isBoxedArray)
((this as IrSimpleType).arguments.single() as IrTypeProjection).type
else {
if (isBoxedArray) {
when (val argument = (this as IrSimpleType).arguments.singleOrNull()) {
is IrTypeProjection ->
argument.type
is IrStarProjection ->
irBuiltIns.anyNType
else ->
error("Unexpected array argument type: $argument")
}
} else {
val classifier = this.classOrNull!!
irBuiltIns.primitiveArrayElementTypes[classifier]
?: throw AssertionError("Primitive array expected: $classifier")