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/typer/Typer.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/typer/Typer.scala')
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 92ef0a266..c6c39f3e2 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -586,10 +586,10 @@ class Typer extends Namer with Applications with Implicits { cpy.ValDef(param, param.mods, param.name, paramTpt, param.rhs) } - /*val resultTpt = + val resultTpt = if (isFullyDefined(protoResult, ForceDegree.none)) untpd.TypeTree(protoResult) - else untpd.TypeTree()*/ - typed(desugar.makeClosure(inferredParams, fnBody/*, resultTpt*/), pt) + else untpd.TypeTree() + typed(desugar.makeClosure(inferredParams, fnBody, resultTpt), pt) } } |