aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorDmitry Petrashko <dark@d-d.me>2014-12-17 12:36:25 +0100
committerDmitry Petrashko <dark@d-d.me>2014-12-17 12:36:25 +0100
commitecbf5f545b46d65858d27173701def9e2a4d113a (patch)
treebba40f6bb76d8221ed2513caa7459fee728a1ba8 /src/dotty/tools
parent3a68e50073e9c4cef06c44e1dec7e3e492eb3274 (diff)
parent625ad7ff89e80f29d425b9dcb2077498b11f4e7c (diff)
downloaddotty-ecbf5f545b46d65858d27173701def9e2a4d113a.tar.gz
dotty-ecbf5f545b46d65858d27173701def9e2a4d113a.tar.bz2
dotty-ecbf5f545b46d65858d27173701def9e2a4d113a.zip
Merge pull request #285 from dotty-staging/fix/catchNonFatal
Fix/catch non fatal
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/Driver.scala12
-rw-r--r--src/dotty/tools/dotc/core/Denotations.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymbolLoaders.scala3
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala3
-rw-r--r--src/dotty/tools/dotc/core/pickling/ClassfileParser.scala3
-rw-r--r--src/dotty/tools/dotc/transform/TreeChecker.scala3
-rw-r--r--src/dotty/tools/dotc/transform/TreeTransform.scala10
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala6
-rw-r--r--src/dotty/tools/dotc/typer/FrontEnd.scala3
-rw-r--r--src/dotty/tools/dotc/typer/ReTyper.scala3
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala1
11 files changed, 32 insertions, 17 deletions
diff --git a/src/dotty/tools/dotc/Driver.scala b/src/dotty/tools/dotc/Driver.scala
index d65d7c1d3..dc1431aca 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,9 @@ 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
}
}
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 09087ac6c..34f9bfbb9 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/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index fe45beb04..c012e8837 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -763,6 +763,12 @@ trait Applications extends Compatibility { self: Typer =>
}
}
+ /** A typed unapply hook, can be overridden by re any-typers between frontend
+ * and pattern matcher.
+ */
+ def typedUnApply(tree: untpd.UnApply, selType: Type)(implicit ctx: Context) =
+ throw new UnsupportedOperationException("cannot type check an UnApply node")
+
/** Is given method reference applicable to type arguments `targs` and argument trees `args`?
* @param resultType The expected result type of the application
*/
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
}
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 1fe770462..97eded7cb 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1021,6 +1021,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
case tree: untpd.PackageDef => typedPackageDef(tree)
case tree: untpd.Annotated => typedAnnotated(tree, pt)
case tree: untpd.TypedSplice => tree.tree
+ case tree: untpd.UnApply => typedUnApply(tree, pt)
case untpd.PostfixOp(tree, nme.WILDCARD) => typedAsFunction(tree, pt)
case untpd.EmptyTree => tpd.EmptyTree
case _ => typedUnadapted(desugar(tree), pt)