diff options
-rw-r--r-- | src/dotty/tools/dotc/Driver.scala | 14 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Denotations.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymbolLoaders.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/pickling/ClassfileParser.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/TreeChecker.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/TreeTransform.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/FrontEnd.scala | 3 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/ReTyper.scala | 3 |
9 files changed, 27 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/Driver.scala b/src/dotty/tools/dotc/Driver.scala index d65d7c1d3..16ed2762e 100644 --- a/src/dotty/tools/dotc/Driver.scala +++ b/src/dotty/tools/dotc/Driver.scala @@ -4,6 +4,7 @@ import config.CompilerCommand import core.Contexts.{Context, ContextBase} import util.DotClass import reporting._ +import scala.util.control.NonFatal abstract class Driver extends DotClass { @@ -29,14 +30,11 @@ abstract class Driver extends DotClass { try { doCompile(newCompiler(), fileNames) } catch { - case ex: Throwable => - ex match { - case ex: FatalError => - ctx.error(ex.getMessage) // signals that we should fail compilation. - ctx.typerState.reporter - case _ => - throw ex // unexpected error, tell the outside world. - } + case ex: FatalError => + ctx.error(ex.getMessage) // signals that we should fail compilation. + ctx.typerState.reporter + case NonFatal(ex) => + throw(ex) // unexpected error, tell the outside world. } } diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index 236bdb7f4..cd585dea1 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -386,7 +386,7 @@ object Denotations { case info: MethodicType => try info.signature catch { // !!! DEBUG - case ex: Throwable => + case scala.util.control.NonFatal(ex) => println(s"cannot take signature of ${info.show}") throw ex } diff --git a/src/dotty/tools/dotc/core/SymbolLoaders.scala b/src/dotty/tools/dotc/core/SymbolLoaders.scala index 886c728b7..76ba3885e 100644 --- a/src/dotty/tools/dotc/core/SymbolLoaders.scala +++ b/src/dotty/tools/dotc/core/SymbolLoaders.scala @@ -14,6 +14,7 @@ import Contexts._, Symbols._, Flags._, SymDenotations._, Types._, Scopes._, util import StdNames._, NameOps._ import Decorators.{StringDecorator, StringInterpolators} import pickling.ClassfileParser +import scala.util.control.NonFatal object SymbolLoaders { /** A marker trait for a completer that replaces the original @@ -206,7 +207,7 @@ abstract class SymbolLoader extends LazyType { } catch { case ex: IOException => signalError(ex) - case ex: Throwable => + case NonFatal(ex) => println(s"exception caught when loading $root: $ex") throw ex } finally { diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 42af31553..076015d99 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -12,6 +12,7 @@ import util.{Stats, DotClass, SimpleMap} import config.Config import config.Printers._ import TypeErasure.{erasedLub, erasedGlb} +import scala.util.control.NonFatal /** Provides methods to compare types. */ @@ -401,7 +402,7 @@ class TypeComparer(initctx: Context) extends DotClass { result } catch { - case ex: Throwable => + case NonFatal(ex) => def showState = { println(disambiguated(implicit ctx => s"assertion failure for ${tp1.show} <:< ${tp2.show}, frozen = $frozenConstraint")) def explainPoly(tp: Type) = tp match { diff --git a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala index f92573d22..8231c25af 100644 --- a/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala +++ b/src/dotty/tools/dotc/core/pickling/ClassfileParser.scala @@ -13,6 +13,7 @@ import scala.collection.mutable.{ ListBuffer, ArrayBuffer } import scala.annotation.switch import typer.Checking.checkNonCyclic import io.AbstractFile +import scala.util.control.NonFatal class ClassfileParser( classfile: AbstractFile, @@ -447,7 +448,7 @@ class ClassfileParser( else Some(Annotation.deferredResolve(attrType, argbuf.toList)) } catch { case f: FatalError => throw f // don't eat fatal errors, they mean a class was not found - case ex: Throwable => + case NonFatal(ex) => // We want to be robust when annotations are unavailable, so the very least // we can do is warn the user about the exception // There was a reference to ticket 1135, but that is outdated: a reference to a class not on diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala index 652536011..1aa681f33 100644 --- a/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -23,6 +23,7 @@ import util.SourcePosition import collection.mutable import ProtoTypes._ import java.lang.AssertionError +import scala.util.control.NonFatal /** Run by -Ycheck option after a given phase, this class retypes all syntax trees * and verifies that the type of each tree node so obtained conforms to the type found in the tree node. @@ -58,7 +59,7 @@ class TreeChecker { val checker = new Checker(previousPhases(phasesToRun.toList)(ctx)) try checker.typedExpr(ctx.compilationUnit.tpdTree)(checkingCtx) catch { - case ex: Throwable => + case NonFatal(ex) => implicit val ctx: Context = checkingCtx println(i"*** error while checking after phase ${checkingCtx.phase.prev} ***") throw ex diff --git a/src/dotty/tools/dotc/transform/TreeTransform.scala b/src/dotty/tools/dotc/transform/TreeTransform.scala index c9d3dcb98..53f326595 100644 --- a/src/dotty/tools/dotc/transform/TreeTransform.scala +++ b/src/dotty/tools/dotc/transform/TreeTransform.scala @@ -16,6 +16,7 @@ import dotty.tools.dotc.core.Decorators._ import dotty.tools.dotc.util.DotClass import scala.annotation.tailrec import config.Printers.transforms +import scala.util.control.NonFatal object TreeTransforms { import tpd._ @@ -1215,6 +1216,8 @@ object TreeTransforms { goOther(tree, info.nx.nxTransOther(cur)) } + private var crashingTree: Tree = EmptyTree + def transform(tree: Tree, info: TransformerInfo, cur: Int)(implicit ctx: Context): Tree = ctx.traceIndented(s"transforming ${tree.show} at ${ctx.phase}", transforms, show = true) { try if (cur < info.transformers.length) { @@ -1228,8 +1231,11 @@ object TreeTransforms { } } else tree catch { - case ex: Throwable => - println(i"exception while transforming $tree of class ${tree.getClass} # ${tree.uniqueId}") + case NonFatal(ex) => + if (tree ne crashingTree) { + crashingTree = tree + println(i"exception while transforming $tree of class ${tree.getClass} # ${tree.uniqueId}") + } throw ex } } diff --git a/src/dotty/tools/dotc/typer/FrontEnd.scala b/src/dotty/tools/dotc/typer/FrontEnd.scala index d276792e7..f6f68d736 100644 --- a/src/dotty/tools/dotc/typer/FrontEnd.scala +++ b/src/dotty/tools/dotc/typer/FrontEnd.scala @@ -8,6 +8,7 @@ import dotty.tools.dotc.parsing.JavaParsers.JavaParser import parsing.Parsers.Parser import config.Printers._ import util.Stats._ +import scala.util.control.NonFatal class FrontEnd extends Phase { @@ -16,7 +17,7 @@ class FrontEnd extends Phase { def monitor(doing: String)(body: => Unit)(implicit ctx: Context) = try body catch { - case ex: Throwable => + case NonFatal(ex) => println(s"exception occured while $doing ${ctx.compilationUnit}") throw ex } diff --git a/src/dotty/tools/dotc/typer/ReTyper.scala b/src/dotty/tools/dotc/typer/ReTyper.scala index a2d4ebad8..901542f21 100644 --- a/src/dotty/tools/dotc/typer/ReTyper.scala +++ b/src/dotty/tools/dotc/typer/ReTyper.scala @@ -9,6 +9,7 @@ import Decorators._ import typer.ProtoTypes._ import ast.{tpd, untpd} import ast.Trees._ +import scala.util.control.NonFatal /** A version of Typer that keeps all symbols defined and referenced in a * previously typed tree. @@ -91,7 +92,7 @@ class ReTyper extends Typer { override def typedUnadapted(tree: untpd.Tree, pt: Type)(implicit ctx: Context) = try super.typedUnadapted(tree, pt) catch { - case ex: Throwable => + case NonFatal(ex) => println(i"exception while typing $tree of class ${tree.getClass} # ${tree.uniqueId}") throw ex } |