From 50bf167d084b78e4c0f4b906ad0587cd29b533dc Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 19 May 2010 22:10:39 +0000 Subject: Closes #3304. Review by extempore. --- src/compiler/scala/tools/nsc/transform/UnCurry.scala | 11 +++++++++-- 1 file 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)) } } -- cgit v1.2.3