diff options
author | Martin Odersky <odersky@gmail.com> | 2013-07-22 15:05:39 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-07-22 15:05:39 +0200 |
commit | 4b265ca213d066897db3a2333a3ac1420e8a480f (patch) | |
tree | e360731eacf61c0fafa9c9a84939ddede0fa0cd5 /src/dotty/tools/dotc/typer/Applications.scala | |
parent | 1ed37543f0dc893ba697c212c310063541018f5c (diff) | |
download | dotty-4b265ca213d066897db3a2333a3ac1420e8a480f.tar.gz dotty-4b265ca213d066897db3a2333a3ac1420e8a480f.tar.bz2 dotty-4b265ca213d066897db3a2333a3ac1420e8a480f.zip |
Added eta-expansion.
Also: made RepeatedParamTypes aliases of their underlying types, in order to avoid any incompatibilities.
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 34 |
1 files changed, 1 insertions, 33 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index cb397a692..7cc35387e 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -8,7 +8,6 @@ import util.Positions._ import Trees.Untyped import Mode.ImplicitsDisabled import Contexts._ -import Types._ import Flags._ import Denotations._ import NameOps._ @@ -19,6 +18,7 @@ import Names._ import StdNames._ import Constants._ import Inferencing._ +import EtaExpansion._ import collection.mutable import language.implicitConversions @@ -70,38 +70,6 @@ trait Applications extends Compatibility{ self: Typer => private def state(implicit ctx: Context) = ctx.typerState - def lift(defs: mutable.ListBuffer[tpd.Tree], expr: tpd.Tree, prefix: String = "")(implicit ctx: Context): tpd.Tree = - if (TreeInfo.isIdempotentExpr(expr)) expr - else { - val name = ctx.freshName(prefix).toTermName - val sym = ctx.newSymbol(ctx.owner, name, EmptyFlags, expr.tpe, coord = positionCoord(expr.pos)) - defs += tpd.ValDef(sym, expr) - tpd.Ident(sym.symRef) - } - - def liftArgs(defs: mutable.ListBuffer[tpd.Tree], methType: Type, args: List[tpd.Tree])(implicit ctx: Context) = { - val paramPrefixes = methType match { - case MethodType(paramNames, _) => paramNames map (_.toString) - case _ => args map (_ => "") - } - for ((arg, prefix) <- args zip paramPrefixes) yield lift(defs, arg, prefix) - } - - def liftApp(defs: mutable.ListBuffer[tpd.Tree], tree: tpd.Tree)(implicit ctx: Context): tpd.Tree = tree match { - case Apply(fn, args) => - tree.derivedApply(liftApp(defs, fn), liftArgs(defs, fn.tpe, args)) - case TypeApply(fn, targs) => - tree.derivedTypeApply(liftApp(defs, fn), targs) - case Select(pre, name) => - tree.derivedSelect(lift(defs, pre), name) - case Ident(name) => - lift(defs, tree) - case Block(stats, expr) => - liftApp(defs ++= stats, expr) - case _ => - tree - } - /** * @param Arg the type of arguments, could be tpd.Tree, untpd.Tree, or Type * @param methRef the reference to the method of the application |