From 25530fbcdf6e44b68df8b3c2d96830bc990ad9b8 Mon Sep 17 00:00:00 2001 From: Tomasz Godzik Date: Fri, 1 Sep 2023 19:56:49 +0200 Subject: [PATCH] bugfix: Catch exception from the compiler for broken shadowed pickles Fixed in Metals: https://github.com/scalameta/metals/pull/5586 [Cherry-picked fa54869e035cda36cc252a8866f6342d85420444] --- .../main/dotty/tools/pc/CompilerSearchVisitor.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala b/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala index 7920e67bc26a..2f7ee282450c 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/CompilerSearchVisitor.scala @@ -22,6 +22,9 @@ class CompilerSearchVisitor( private def isAccessible(sym: Symbol): Boolean = try sym != NoSymbol && sym.isPublic && sym.isStatic catch + case err: AssertionError => + logger.log(Level.WARNING, err.getMessage()) + false case NonFatal(e) => reports.incognito.create( Report( @@ -64,8 +67,14 @@ class CompilerSearchVisitor( .stripSuffix("$") .split("\\$") - val added = toSymbols(pkg, innerPath.toList).filter(visitSymbol) + val added = + try toSymbols(pkg, innerPath.toList).filter(visitSymbol) + catch + case NonFatal(e) => + logger.log(Level.WARNING, e.getMessage(), e) + Nil added.size + end visitClassfile def visitWorkspaceSymbol( path: java.nio.file.Path,