summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Suereth <Joshua.Suereth@gmail.com>2012-05-16 04:53:05 -0700
committerJosh Suereth <Joshua.Suereth@gmail.com>2012-05-16 04:53:05 -0700
commit8a42d535dbef45bc18cf4232912842dddd85d1e4 (patch)
tree56edc480bbbd712f31118f6592428457266988f9 /src
parente0e1ac5f66caf011ccc27ea993653fc4f87f726b (diff)
parente33901084242b4d7cd76a9279430d0cbc9b9a152 (diff)
downloadscala-8a42d535dbef45bc18cf4232912842dddd85d1e4.tar.gz
scala-8a42d535dbef45bc18cf4232912842dddd85d1e4.tar.bz2
scala-8a42d535dbef45bc18cf4232912842dddd85d1e4.zip
Merge pull request #557 from lrytz/wip/t5610
Fix for SI-5610
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
index 92ce0e6de4..e1fb683aa9 100644
--- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala
@@ -63,15 +63,18 @@ trait EtaExpansion { self: Analyzer =>
* @return ...
*/
def liftoutPrefix(tree: Tree): Tree = {
- def liftout(tree: Tree): Tree =
+ def liftout(tree: Tree, byName: Boolean): Tree =
if (treeInfo.isExprSafeToInline(tree)) tree
else {
val vname: Name = freshName()
// Problem with ticket #2351 here
defs += atPos(tree.pos) {
- ValDef(Modifiers(SYNTHETIC), vname.toTermName, TypeTree(), tree)
+ val rhs = if (byName) Function(List(), tree) else tree
+ ValDef(Modifiers(SYNTHETIC), vname.toTermName, TypeTree(), rhs)
+ }
+ atPos(tree.pos.focus) {
+ if (byName) Apply(Ident(vname), List()) else Ident(vname)
}
- Ident(vname) setPos tree.pos.focus
}
val tree1 = tree match {
// a partial application using named arguments has the following form:
@@ -85,11 +88,14 @@ trait EtaExpansion { self: Analyzer =>
defs ++= stats
liftoutPrefix(fun)
case Apply(fn, args) =>
- treeCopy.Apply(tree, liftoutPrefix(fn), args mapConserve (liftout)) setType null
+ 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) }
+ treeCopy.Apply(tree, liftoutPrefix(fn), newArgs) setType null
case TypeApply(fn, args) =>
treeCopy.TypeApply(tree, liftoutPrefix(fn), args) setType null
case Select(qual, name) =>
- treeCopy.Select(tree, liftout(qual), name) setSymbol NoSymbol setType null
+ treeCopy.Select(tree, liftout(qual, false), name) setSymbol NoSymbol setType null
case Ident(name) =>
tree
}