diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-28 21:46:05 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-28 21:46:05 +0100 |
commit | 3c8196300d65738d6779ba8703e2a86ee3390ec7 (patch) | |
tree | d8edb5ee7eff6c2e012c0fef9e73938d7f3eeacc /src/dotty/tools/dotc/typer/Applications.scala | |
parent | 53c0d8996c5d065bff2f860948e5c563b187d221 (diff) | |
download | dotty-3c8196300d65738d6779ba8703e2a86ee3390ec7.tar.gz dotty-3c8196300d65738d6779ba8703e2a86ee3390ec7.tar.bz2 dotty-3c8196300d65738d6779ba8703e2a86ee3390ec7.zip |
New version of eta-expansion.
This version expands a method ref p.m to the untyped tree
p.m(_, ..., _)
(after lifting impure expressions from p). Afterwards the usual application mechanisms kick in. This fixes problems also present in Scala 2.x, where an eta-expanded function was not as flexible as an explicitly expanded one (for instance, eta expansion did not honor default parameters).
Diffstat (limited to 'src/dotty/tools/dotc/typer/Applications.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 27e142e55..aa2227d63 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -26,8 +26,12 @@ import reflect.ClassTag import language.implicitConversions object Applications { + import tpd._ private val isNamedArg = (arg: Any) => arg.isInstanceOf[Trees.NamedArg[_]] def hasNamedArg(args: List[Any]) = args exists isNamedArg + + def wrapDefs(defs: mutable.ListBuffer[Tree], tree: Tree)(implicit ctx: Context): Tree = + if (defs != null && defs.nonEmpty) tpd.Block(defs.toList, tree) else tree } import Applications._ |