diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index 747b719cb881..1a723a79204c 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -111,7 +111,8 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint } catch { case NonFatal(ex) => - runContext.echo(i"exception occurred while compiling $units%, %") + if units != null then runContext.echo(i"exception occurred while compiling $units%, %") + else runContext.echo(s"exception occurred while compiling ${fileNames.mkString(", ")}") throw ex } diff --git a/compiler/src/dotty/tools/dotc/core/Contexts.scala b/compiler/src/dotty/tools/dotc/core/Contexts.scala index b54f6d320693..232a893072ff 100644 --- a/compiler/src/dotty/tools/dotc/core/Contexts.scala +++ b/compiler/src/dotty/tools/dotc/core/Contexts.scala @@ -36,6 +36,7 @@ import util.Store import xsbti.AnalysisCallback import plugins._ import java.util.concurrent.atomic.AtomicInteger +import java.nio.file.InvalidPathException object Contexts { @@ -248,11 +249,16 @@ object Contexts { def getSource(path: TermName): SourceFile = base.sourceNamed.get(path) match { case Some(source) => source - case None => + case None => try { val f = new PlainFile(Path(path.toString)) val src = getSource(f) base.sourceNamed(path) = src src + } catch { + case ex: InvalidPathException => + ctx.error(s"invalid file path: ${ex.getMessage}") + NoSource + } } /** Sourcefile with given path, memoized */