summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 38c675b5e9..0270323133 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -403,8 +403,15 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
Select(predef, "wrap"+elemtp.typeSymbol.name+"Array")
else
TypeApply(Select(predef, "genericWrapArray"), List(TypeTree(elemtp)))
- val adaptedTree = // need to cast to Array[elemtp], as arrays are not covariant
- gen.mkCast(tree, arrayType(elemtp))
+ val pt = arrayType(elemtp)
+ val adaptedTree = // might need to cast to Array[elemtp], as arrays are not covariant
+ if (tree.tpe <:< pt) tree
+ else gen.mkCast(
+ if (elemtp.typeSymbol == AnyClass && isValueClass(tree.tpe.typeArgs.head.typeSymbol))
+ gen.mkRuntimeCall("toObjectArray", List(tree))
+ else
+ tree,
+ arrayType(elemtp))
Apply(meth, List(adaptedTree))
}
}