diff options
author | Martin Odersky <odersky@gmail.com> | 2005-10-22 03:06:38 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-10-22 03:06:38 +0000 |
commit | b2846fa014e0dcc78bd4365e44dd088db7059fc2 (patch) | |
tree | 93bf92389bbaf5db750197408145630d35df2e46 /sources | |
parent | 917a34ff6531ad58543aed4cb5b67f1745ee353b (diff) | |
download | scala-b2846fa014e0dcc78bd4365e44dd088db7059fc2.tar.gz scala-b2846fa014e0dcc78bd4365e44dd088db7059fc2.tar.bz2 scala-b2846fa014e0dcc78bd4365e44dd088db7059fc2.zip |
*** empty log message ***
Diffstat (limited to 'sources')
-rw-r--r-- | sources/scala/tools/nsc/ast/Trees.scala | 13 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/transform/UnCurry.scala | 3 | ||||
-rwxr-xr-x | sources/scala/tools/nsc/typechecker/Infer.scala | 2 |
3 files changed, 17 insertions, 1 deletions
diff --git a/sources/scala/tools/nsc/ast/Trees.scala b/sources/scala/tools/nsc/ast/Trees.scala index 808d876172..e72959211e 100644 --- a/sources/scala/tools/nsc/ast/Trees.scala +++ b/sources/scala/tools/nsc/ast/Trees.scala @@ -1057,6 +1057,19 @@ import symtab.Flags._; } } + class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer { + override def transform(tree: Tree): Tree = tree match { + case Ident(_) => + def subst(from: List[Symbol], to: List[Tree]): Tree = + if (from.isEmpty) tree + else if (tree.symbol == from.head) to.head + else subst(from.tail, to.tail); + subst(from, to) + case _ => + super.transform(tree) + } + } + class TreeTypeSubstituter(from: List[Symbol], to: List[Type]) extends Traverser { val typeSubst = new SubstTypeMap(from, to); override def traverse(tree: Tree): unit = { diff --git a/sources/scala/tools/nsc/transform/UnCurry.scala b/sources/scala/tools/nsc/transform/UnCurry.scala index e62bb20739..97d35b0004 100755 --- a/sources/scala/tools/nsc/transform/UnCurry.scala +++ b/sources/scala/tools/nsc/transform/UnCurry.scala @@ -195,6 +195,9 @@ abstract class UnCurry extends InfoTransform { } def mainTransform(tree: Tree): Tree = (tree match { + case Apply(Select(Block(List(), Function(vparams, body)), nme.apply), args) => + // perform beta-reduction; this helps keep view applications small + mainTransform(new TreeSubstituter(vparams map (.symbol), args).transform(body)) case Apply(fn, args) => val formals = fn.tpe.paramTypes; copy.Apply(tree, transform(fn), transformTrees(transformArgs(tree.pos, args, formals))) diff --git a/sources/scala/tools/nsc/typechecker/Infer.scala b/sources/scala/tools/nsc/typechecker/Infer.scala index 14ea5dbd16..9ffe4f9983 100755 --- a/sources/scala/tools/nsc/typechecker/Infer.scala +++ b/sources/scala/tools/nsc/typechecker/Infer.scala @@ -139,7 +139,7 @@ package scala.tools.nsc.typechecker; * A nullary method type becomes its result type. * Implicit parameters are skipped. */ - private def normalize(tp: Type): Type = skipImplicit(tp) match { + def normalize(tp: Type): Type = skipImplicit(tp) match { case MethodType(formals, restpe) => if (util.Statistics.enabled) normM = normM + 1; functionType(formals, normalize(restpe)) |