diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 57aab549cfd5..d789ad64e969 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -715,7 +715,7 @@ class Typer extends Namer def escapingRefs(block: Tree, localSyms: => List[Symbol])(implicit ctx: Context): collection.Set[NamedType] = { lazy val locals = localSyms.toSet - block.tpe namedPartsWith (tp => locals.contains(tp.symbol)) + block.tpe.namedPartsWith(tp => locals.contains(tp.symbol) && !tp.isErroneous) } /** Ensure that an expression's type can be expressed without references to locally defined