diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-18 12:42:57 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-18 12:42:57 +0100 |
commit | 766379f578ab2ae05b2a94fc9c51e8a47e25b9ff (patch) | |
tree | 39e881bdd9a4f94019214755640d3d316eb7e5b5 | |
parent | 15d8a2e9804fe55c9261e195088da55c0eaa6803 (diff) | |
download | dotty-766379f578ab2ae05b2a94fc9c51e8a47e25b9ff.tar.gz dotty-766379f578ab2ae05b2a94fc9c51e8a47e25b9ff.tar.bz2 dotty-766379f578ab2ae05b2a94fc9c51e8a47e25b9ff.zip |
Allowing curried closures.
-rw-r--r-- | src/dotty/tools/dotc/ast/tpd.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/EtaExpansion.scala | 2 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/ast/tpd.scala b/src/dotty/tools/dotc/ast/tpd.scala index b66b4d017..195797b2b 100644 --- a/src/dotty/tools/dotc/ast/tpd.scala +++ b/src/dotty/tools/dotc/ast/tpd.scala @@ -123,8 +123,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { * where the closure's type is the target type of the expression (FunctionN, unless * otherwise specified). */ - def Closure(meth: TermSymbol, bodyFn: List[Tree] => Tree, targetType: Type = NoType)(implicit ctx: Context): Block = { - val rhsFn: List[List[Tree]] => Tree = { case args :: Nil => bodyFn(args) } + def Closure(meth: TermSymbol, rhsFn: List[List[Tree]] => Tree, targetType: Type = NoType)(implicit ctx: Context): Block = { val targetTpt = if (targetType.exists) TypeTree(targetType) else EmptyTree Block( DefDef(meth, rhsFn) :: Nil, diff --git a/src/dotty/tools/dotc/typer/EtaExpansion.scala b/src/dotty/tools/dotc/typer/EtaExpansion.scala index 26a2af231..782e5382f 100644 --- a/src/dotty/tools/dotc/typer/EtaExpansion.scala +++ b/src/dotty/tools/dotc/typer/EtaExpansion.scala @@ -112,7 +112,7 @@ object EtaExpansion { def etaExpand(tree: Tree, tpe: MethodType)(implicit ctx: Context): Tree = { def expand(lifted: Tree): Tree = { val meth = ctx.newSymbol(ctx.owner, nme.ANON_FUN, Synthetic, tpe, coord = tree.pos) - Closure(meth, Apply(lifted, _)) + Closure(meth, argss => (lifted /: argss)(Apply(_, _))) } val defs = new mutable.ListBuffer[Tree] val lifted = liftApp(defs, tree) |