diff options
author | Martin Odersky <odersky@gmail.com> | 2014-01-02 16:04:04 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2014-01-02 16:04:17 +0100 |
commit | 09fdc8ee5705a80c361d3c07c49a5a660809a222 (patch) | |
tree | 19b1829d57455ddb53c80da6d7140c7fdc61749f /src/dotty/tools/dotc/ast/Desugar.scala | |
parent | 502ad2204e0f286f3a1f7c343161613bd85dfb14 (diff) | |
download | dotty-09fdc8ee5705a80c361d3c07c49a5a660809a222.tar.gz dotty-09fdc8ee5705a80c361d3c07c49a5a660809a222.tar.bz2 dotty-09fdc8ee5705a80c361d3c07c49a5a660809a222.zip |
Taking a fully-defined result type into account when forming a closure.
Given
(params) => body
and an expected type
Ts => R
with R fully defined, we use R as the result type of the closure def into which the function is translated.
Note: It would be nice generalize this further to result types which are not fully defined, yet this would complicate things by entangling typing and desugaring.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 54ea96eed..7b483adb9 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -420,9 +420,9 @@ object desugar { * def $anonfun(params) = body * Closure($anonfun) */ - def makeClosure(params: List[ValDef], body: Tree) = + def makeClosure(params: List[ValDef], body: Tree, tpt: Tree = TypeTree()) = Block( - DefDef(Modifiers(Synthetic), nme.ANON_FUN, Nil, params :: Nil, TypeTree(), body), + DefDef(Modifiers(Synthetic), nme.ANON_FUN, Nil, params :: Nil, tpt, body), Closure(Nil, Ident(nme.ANON_FUN), EmptyTree)) /** Expand partial function |