diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2012-06-23 19:04:50 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2012-06-23 19:22:22 +0200 |
commit | 4736897ad2a6425c64cadfe80d5e6d7751ee0fec (patch) | |
tree | 530a4a95010fe8f8d8daf509cb552fa61ce739d7 /src | |
parent | ff016002738580a7de11977c91e0061dbcf270ad (diff) | |
download | scala-4736897ad2a6425c64cadfe80d5e6d7751ee0fec.tar.gz scala-4736897ad2a6425c64cadfe80d5e6d7751ee0fec.tar.bz2 scala-4736897ad2a6425c64cadfe80d5e6d7751ee0fec.zip |
SI-5966 Fix eta expansion for repeated parameters with zero arguments.
Reworks part of e33901 / SI-5610, which was inserting an <empty> tree
as an argument in this case, which turns into a null in icode.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index e1fb683aa9..177d1ddf19 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -88,9 +88,11 @@ trait EtaExpansion { self: Analyzer => defs ++= stats liftoutPrefix(fun) case Apply(fn, args) => - val byName = fn.tpe.params.map(p => definitions.isByNameParamType(p.tpe)) - // zipAll: with repeated params, there might be more args than params - val newArgs = args.zipAll(byName, EmptyTree, false) map { case (arg, byN) => liftout(arg, byN) } + val byName: Int => Option[Boolean] = fn.tpe.params.map(p => definitions.isByNameParamType(p.tpe)).lift + val newArgs = mapWithIndex(args) { (arg, i) => + // with repeated params, there might be more or fewer args than params + liftout(arg, byName(i).getOrElse(false)) + } treeCopy.Apply(tree, liftoutPrefix(fn), newArgs) setType null case TypeApply(fn, args) => treeCopy.TypeApply(tree, liftoutPrefix(fn), args) setType null |