diff --git a/compiler/src/dotty/tools/dotc/interactive/Interactive.scala b/compiler/src/dotty/tools/dotc/interactive/Interactive.scala index e884429b97cd..0e1456764088 100644 --- a/compiler/src/dotty/tools/dotc/interactive/Interactive.scala +++ b/compiler/src/dotty/tools/dotc/interactive/Interactive.scala @@ -344,7 +344,7 @@ object Interactive { if (tree.pos.contains(pos)) { // FIXME: We shouldn't need a cast. Change NavigateAST.pathTo to return a List of Tree? val path = NavigateAST.pathTo(pos, tree, skipZeroExtent = true).asInstanceOf[List[untpd.Tree]] - path.dropWhile(!_.hasType).asInstanceOf[List[tpd.Tree]] + path.dropWhile(!_.hasType) collect { case t: tpd.Tree @unchecked => t } } else Nil @@ -365,7 +365,7 @@ object Interactive { case nested :: encl :: rest => import typer.Typer._ val outer = contextOfPath(encl :: rest) - encl match { + try encl match { case tree @ PackageDef(pkg, stats) => assert(tree.symbol.exists) if (nested `eq` pkg) outer @@ -401,6 +401,9 @@ object Interactive { case _ => outer } + catch { + case ex: CyclicReference => outer + } } /** The first tree in the path that is a definition. */ diff --git a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala index 3940547ffa81..8d2b0f434c64 100644 --- a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala +++ b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala @@ -148,20 +148,24 @@ class InteractiveDriver(settings: List[String]) extends Driver { val names = new mutable.ListBuffer[String] dirClassPaths.foreach { dirCp => val root = dirCp.dir.toPath - Files.walkFileTree(root, new SimpleFileVisitor[Path] { - override def visitFile(path: Path, attrs: BasicFileAttributes) = { - if (!attrs.isDirectory) { - val name = path.getFileName.toString - for { - tastySuffix <- tastySuffixes - if name.endsWith(tastySuffix) - } { - names += root.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix) + try + Files.walkFileTree(root, new SimpleFileVisitor[Path] { + override def visitFile(path: Path, attrs: BasicFileAttributes) = { + if (!attrs.isDirectory) { + val name = path.getFileName.toString + for { + tastySuffix <- tastySuffixes + if name.endsWith(tastySuffix) + } { + names += root.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix) + } } + FileVisitResult.CONTINUE } - FileVisitResult.CONTINUE - } - }) + }) + catch { + case _: NoSuchFileException => + } } names.toList }