From cd74cac72d0ef45894a4437a986d981390e47f0b Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 1 Jul 2019 19:07:38 +0200 Subject: [PATCH 1/2] Fix leak checking When compiling Parsers.scala with mismatched braces, I saw ``` java.lang.AssertionError: assertion failed: leak: [error] ( [error] vdef) in ... ``` The issue is here that we should disregard leaks with erroneous types. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 57aab549cfd5..d775d7d52648 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.widen.isErroneous) } /** Ensure that an expression's type can be expressed without references to locally defined From a38a6a7316527c0b284fae73b3fa325cb7eaf59e Mon Sep 17 00:00:00 2001 From: odersky Date: Mon, 1 Jul 2019 21:43:25 +0200 Subject: [PATCH 2/2] Update compiler/src/dotty/tools/dotc/typer/Typer.scala Co-Authored-By: Guillaume Martres --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index d775d7d52648..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) && !tp.widen.isErroneous) + block.tpe.namedPartsWith(tp => locals.contains(tp.symbol) && !tp.isErroneous) } /** Ensure that an expression's type can be expressed without references to locally defined