Skip to content

Commit 11505f2

Browse files
committed
Fix DenotationNotDefinedHere in pattern matcher
This was uncovered by previous commit "Fix isSubType bug ...". Also removed two redundants ".fresh" calls in "fresh.addMode".
1 parent 1ca0fb7 commit 11505f2

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/dotty/tools/dotc/core/Decorators.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ object Decorators {
173173
def treatSingleArg(arg: Any) : Any =
174174
try
175175
arg match {
176-
case arg: Showable => arg.show(ctx.fresh.addMode(Mode.FutureDefsOK))
176+
case arg: Showable => arg.show(ctx.addMode(Mode.FutureDefsOK))
177177
case _ => arg
178178
}
179179
catch {

src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ class TreeUnpickler(reader: TastyReader, tastyName: TastyName.Table) {
720720
case SELECT =>
721721
def readQual(name: Name) = {
722722
val localCtx =
723-
if (name == nme.CONSTRUCTOR) ctx.fresh.addMode(Mode.InSuperCall) else ctx
723+
if (name == nme.CONSTRUCTOR) ctx.addMode(Mode.InSuperCall) else ctx
724724
readTerm()(localCtx)
725725
}
726726
def readRest(name: Name, sig: Signature) = {

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import ast.Trees._
2121
import Applications._
2222
import TypeApplications._
2323
import SymUtils._, core.NameOps._
24+
import typer.Mode
2425

2526
import dotty.tools.dotc.util.Positions.Position
2627
import dotty.tools.dotc.core.Decorators._
@@ -464,8 +465,9 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
464465
// all potentially stored subpat binders
465466
val potentiallyStoredBinders = stored.unzip._1.toSet
466467
// compute intersection of all symbols in the tree `in` and all potentially stored subpat binders
467-
new DeepFolder[Unit]((x: Unit, t:Tree) =>
468+
def computeBinders(implicit ctx: Context) = new DeepFolder[Unit]((x: Unit, t:Tree) =>
468469
if (potentiallyStoredBinders(t.symbol)) usedBinders += t.symbol).apply((), in)
470+
computeBinders(ctx.addMode(Mode.FutureDefsOK)) // trigged a NotDefinedHere on $outer when compiler dotc/printing
469471

470472
if (usedBinders.isEmpty) in
471473
else {

0 commit comments

Comments
 (0)