diff options
author | Martin Odersky <odersky@gmail.com> | 2006-05-19 13:21:50 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2006-05-19 13:21:50 +0000 |
commit | 16b00da844c40cc76cee72088bd6dc49fa38d98c (patch) | |
tree | 85c1d28e29914ce32f9ab49adc1f4347d6d54909 /src/compiler/scala/tools/nsc/transform/UnCurry.scala | |
parent | c05a58bd3453ceba0215bd9d2bd49cd6dfe8745d (diff) | |
download | scala-16b00da844c40cc76cee72088bd6dc49fa38d98c.tar.gz scala-16b00da844c40cc76cee72088bd6dc49fa38d98c.tar.bz2 scala-16b00da844c40cc76cee72088bd6dc49fa38d98c.zip |
Fixed bug 601,602,603
Diffstat (limited to 'src/compiler/scala/tools/nsc/transform/UnCurry.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/transform/UnCurry.scala | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala index d2955bf9e5..3a87b7c25c 100644 --- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala +++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala @@ -73,6 +73,7 @@ abstract class UnCurry extends InfoTransform { private var inPattern = false; private var inConstructorFlag = 0L; private var localTyper: analyzer.Typer = analyzer.newTyper(analyzer.rootContext(unit)); + private var byNameArgs = new HashSet[Tree](16) override def transform(tree: Tree): Tree = try { //debug postTransform(mainTransform(tree)); @@ -86,10 +87,10 @@ abstract class UnCurry extends InfoTransform { * x.apply()? Note that this is not the case if `x' is used as an argument to another * call by name parameter. */ - def isByNameRef(tree: Tree): boolean = ( + def isByNameRef(tree: Tree): boolean = tree.isTerm && tree.hasSymbol && - tree.symbol.tpe.symbol == ByNameParamClass && tree.tpe == tree.symbol.tpe.typeArgs.head - ); + tree.symbol.tpe.symbol == ByNameParamClass && + !byNameArgs.contains(tree) /** Uncurry a type of a tree node. * This function is sensitive to whether or not we are in a pattern -- when in a pattern @@ -266,15 +267,19 @@ abstract class UnCurry extends InfoTransform { } case _ => args } - List.map2(formals, args1) ((formal, arg) => - if (formal.symbol != ByNameParamClass) arg - else if (isByNameRef(arg)) arg setType functionType(List(), arg.tpe) - else { + List.map2(formals, args1) { (formal, arg) => + if (formal.symbol != ByNameParamClass) { + arg + } else if (isByNameRef(arg)) { + byNameArgs.addEntry(arg) + arg setType functionType(List(), arg.tpe) + } else { val fun = localTyper.atOwner(currentOwner).typed( Function(List(), arg) setPos arg.pos).asInstanceOf[Function]; new ChangeOwnerTraverser(currentOwner, fun.symbol).traverse(arg); transformFunction(fun) - }) + } + } } } |