diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-22 18:02:53 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-22 18:02:53 +0000 |
commit | db4bf36110a922bd41a900a90fb2c158280d027b (patch) | |
tree | ef2e829cf2133b36c94fa1623e6778800346c4cd /src/compiler | |
parent | d5533fbf7020b316b77ea8f52eba96249eb6d881 (diff) | |
download | scala-db4bf36110a922bd41a900a90fb2c158280d027b.tar.gz scala-db4bf36110a922bd41a900a90fb2c158280d027b.tar.bz2 scala-db4bf36110a922bd41a900a90fb2c158280d027b.zip |
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.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/UnCurry.scala | 10 |
1 files changed, 6 insertions, 4 deletions
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) { |