From 44f0976487792760f0dc7fc8aa3dc1ba4ac52b7f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 24 Oct 2013 13:29:40 +0200 Subject: Added forgfeotten withNewScope when typing value definitions. ValDefs need to open a new scope for anything that's declared on the right hand side. --- src/dotty/tools/dotc/typer/Namer.scala | 5 +++-- src/dotty/tools/dotc/typer/Typer.scala | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/typer') diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 7582b0d0d..79b1750dc 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -89,7 +89,8 @@ class Namer { typer: Typer => /** The scope of the typer. * For nested typers this is a place parameters are entered during completion - * and where they survive until typechecking. + * and where they survive until typechecking. A context with this typer also + * has this scope. */ val scope = newScope @@ -278,7 +279,7 @@ class Namer { typer: Typer => def typeSig(tree: Tree): Type = tree match { case tree: ValDef => - valOrDefDefSig(tree, sym, identity)(localContext) + valOrDefDefSig(tree, sym, identity)(localContext.withNewScope) case tree: DefDef => val typer1 = new Typer nestedTyper(sym) = typer1 diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 840bee467..5b79c62f3 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -806,7 +806,7 @@ class Typer extends Namer with Applications with Implicits { case tree: untpd.Bind => typedBind(tree, pt) case tree: untpd.ValDef => if (tree.isEmpty) tpd.EmptyValDef - else typedValDef(tree, sym)(localContext) + else typedValDef(tree, sym)(localContext.withNewScope) case tree: untpd.DefDef => val typer1 = nestedTyper.remove(sym).get typer1.typedDefDef(tree, sym)(localContext.withTyper(typer1)) -- cgit v1.2.3