From afa83000f39f0b10824cb11b84ab0e8b66a91241 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 24 Oct 2013 17:39:10 +0200 Subject: Parsing and desugaring fixes for blocks. Previously, { () } was expanded to { (); EmptyTree }, because the empty tuple is not a term tree. Now EmptyTree is inserted only after a definition. Furthermore, blocks ending in EmptyTree are now replaced by blocks that end in a unit literal. --- src/dotty/tools/dotc/typer/Typer.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/typer/Typer.scala') diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 5b79c62f3..bb3e1052a 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -461,8 +461,9 @@ class Typer extends Namer with Applications with Implicits { else if (forceFullyDefined(pt)) { val expr2 = typed(untpd.Typed(untpd.TypedSplice(expr1), untpd.TypeTree(pt))) untpd.Block(stats1, expr2) withType expr2.tpe - } else errorTree(result, - i"local definition of ${leaks.head.name} escapes as part of block's type ${result.tpe}") + } else + errorTree(result, + i"local definition of ${leaks.head.name} escapes as part of block's type ${result.tpe}") } def typedIf(tree: untpd.If, pt: Type)(implicit ctx: Context) = track("typedIf") { @@ -825,7 +826,7 @@ class Typer extends Namer with Applications with Implicits { case tree: untpd.Typed => typedTyped(tree, pt) case tree: untpd.NamedArg => typedNamedArg(tree, pt) case tree: untpd.Assign => typedAssign(tree, pt) - case tree: untpd.Block => typedBlock(tree, pt) + case tree: untpd.Block => typedBlock(desugar.block(tree), pt) case tree: untpd.If => typedIf(tree, pt) case tree: untpd.Function => typedFunction(tree, pt) case tree: untpd.Closure => typedClosure(tree, pt) -- cgit v1.2.3