diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/Driver.scala | 7 | ||||
-rw-r--r-- | src/dotty/tools/dotc/reporting/Reporter.scala | 7 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/Driver.scala b/src/dotty/tools/dotc/Driver.scala index 3b382da58..22170a478 100644 --- a/src/dotty/tools/dotc/Driver.scala +++ b/src/dotty/tools/dotc/Driver.scala @@ -50,8 +50,13 @@ abstract class Driver extends DotClass { process(args, initCtx) } - def main(args: Array[String]): Unit = + def main(args: Array[String]): Unit = { + // Preload scala.util.control.NonFatal. Otherwise, when trying to catch a StackOverflowError, + // we may try to load it but fail with another StackOverflowError and lose the original exception, + // see <https://groups.google.com/forum/#!topic/scala-user/kte6nak-zPM>. + val _ = NonFatal sys.exit(if (process(args).hasErrors) 1 else 0) + } } class FatalError(msg: String) extends Exception diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index 4a72c2066..5cad0a077 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -152,7 +152,12 @@ trait Reporting { this: Context => case _ => String.valueOf(res) } if (printer eq config.Printers.noPrinter) op - else traceIndented[T](s"==> $question?", (res: Any) => s"<== $question = ${resStr(res)}")(op) + else { + // Avoid evaluating question multiple time, since each evaluation + // may cause some extra logging output. + val q: String = question + traceIndented[T](s"==> $q?", (res: Any) => s"<== $q = ${resStr(res)}")(op) + } } def traceIndented[T](leading: => String, trailing: Any => String)(op: => T): T = |