From 74490a2315ce8c38fdf6905e713e57005bf085c7 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Sun, 17 May 2015 13:27:38 +0200 Subject: Fix DenotationNotDefinedHere in pattern matcher This was uncovered by previous commit "Fix isSubType bug ...". Also removed two redundants ".fresh" calls in "fresh.addMode". --- src/dotty/tools/dotc/core/Decorators.scala | 2 +- src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala | 2 +- src/dotty/tools/dotc/transform/PatternMatcher.scala | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/dotty/tools/dotc/core/Decorators.scala b/src/dotty/tools/dotc/core/Decorators.scala index 8aaef985c..d90b959ab 100644 --- a/src/dotty/tools/dotc/core/Decorators.scala +++ b/src/dotty/tools/dotc/core/Decorators.scala @@ -173,7 +173,7 @@ object Decorators { def treatSingleArg(arg: Any) : Any = try arg match { - case arg: Showable => arg.show(ctx.fresh.addMode(Mode.FutureDefsOK)) + case arg: Showable => arg.show(ctx.addMode(Mode.FutureDefsOK)) case _ => arg } catch { diff --git a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 84d497b9c..e753bdcab 100644 --- a/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -720,7 +720,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) { case SELECT => def readQual(name: Name) = { val localCtx = - if (name == nme.CONSTRUCTOR) ctx.fresh.addMode(Mode.InSuperCall) else ctx + if (name == nme.CONSTRUCTOR) ctx.addMode(Mode.InSuperCall) else ctx readTerm()(localCtx) } def readRest(name: Name, sig: Signature) = { diff --git a/src/dotty/tools/dotc/transform/PatternMatcher.scala b/src/dotty/tools/dotc/transform/PatternMatcher.scala index d665aa0c5..507dbb0ce 100644 --- a/src/dotty/tools/dotc/transform/PatternMatcher.scala +++ b/src/dotty/tools/dotc/transform/PatternMatcher.scala @@ -21,6 +21,7 @@ import ast.Trees._ import Applications._ import TypeApplications._ import SymUtils._, core.NameOps._ +import typer.Mode import dotty.tools.dotc.util.Positions.Position import dotty.tools.dotc.core.Decorators._ @@ -464,8 +465,9 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans // all potentially stored subpat binders val potentiallyStoredBinders = stored.unzip._1.toSet // compute intersection of all symbols in the tree `in` and all potentially stored subpat binders - new DeepFolder[Unit]((x: Unit, t:Tree) => + def computeBinders(implicit ctx: Context) = new DeepFolder[Unit]((x: Unit, t:Tree) => if (potentiallyStoredBinders(t.symbol)) usedBinders += t.symbol).apply((), in) + computeBinders(ctx.addMode(Mode.FutureDefsOK)) // trigged a NotDefinedHere on $outer when compiler dotc/printing if (usedBinders.isEmpty) in else { -- cgit v1.2.3