Support varargs of inline class types with non-trivial spread

#KT-24880 In Progress
This commit is contained in:
Mikhail Zarechenskiy
2018-06-25 00:38:17 +03:00
parent 333411c57d
commit ba6da7c40a
4 changed files with 53 additions and 2 deletions
@@ -2898,6 +2898,18 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
KotlinType argumentKotlinType = kotlinType(argumentExpression);
if (argument.getSpreadElement() != null) {
gen(argumentExpression, OBJECT_TYPE, argumentKotlinType);
if (argumentKotlinType != null && InlineClassesUtilsKt.isInlineClassType(argumentKotlinType)) {
// we're going to pass value of inline class type to j/l/Object, which would result in boxing and then
// will cause check cast error on toArray() call. To mitigate this problem, we unbox this value and pass
// primitive array to the method. Note that bytecode optimisations will remove box/unbox calls.
StackValue.coerce(
OBJECT_TYPE, argumentKotlinType,
asmType(argumentKotlinType), argumentKotlinType,
v
);
}
v.invokevirtual(owner, "addSpread", "(Ljava/lang/Object;)V", false);
}
else {