From db4bf36110a922bd41a900a90fb2c158280d027b Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Wed, 22 Dec 2010 18:02:53 +0000 Subject: Recognize calls to scala varargs methods where ... Recognize calls to scala varargs methods where the parameter list is empty, and give Nil as the sequence rather than wrapping an empty Array. Review by odersky. --- src/compiler/scala/tools/nsc/transform/UnCurry.scala | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index aa3086c05b..bbb457b12e 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -434,10 +434,12 @@ abstract class UnCurry extends InfoTransform with TypingTransformers with ast.Tr else if (tree.tpe.typeSymbol isSubClass TraversableClass) tree // @PP: I suspect this should be SeqClass else arrayToSequence(tree, varargsElemType) - } else { - val tree = mkArrayValue(args drop (formals.length - 1), varargsElemType) - if (isJava || inPattern) tree - else arrayToSequence(tree, varargsElemType) + } + else { + def mkArray = mkArrayValue(args drop (formals.length - 1), varargsElemType) + if (isJava || inPattern) mkArray + else if (args.isEmpty) gen.mkNil // avoid needlessly double-wrapping an empty argument list + else arrayToSequence(mkArray, varargsElemType) } atPhase(phase.next) { -- cgit v1.2.3