aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-12-14 19:15:18 +0100
committerMartin Odersky <odersky@gmail.com>2014-12-15 16:36:53 +0100
commit332b1af33441b382b3e1efa68c5dab4fcda8b2bc (patch)
treeb04a52702b09d8423fc053f88e1883940e27b600 /src/dotty/tools/dotc/core
parent0eec180a686a4425bd3f3089006eda530123fe2e (diff)
downloaddotty-332b1af33441b382b3e1efa68c5dab4fcda8b2bc.tar.gz
dotty-332b1af33441b382b3e1efa68c5dab4fcda8b2bc.tar.bz2
dotty-332b1af33441b382b3e1efa68c5dab4fcda8b2bc.zip
Replace Throwable catches with NonFatal
Previously, stackoverflows led to infinite loops because the catch immediately threw another stack overflow. Anyway, one should never catch Throwable.
Diffstat (limited to 'src/dotty/tools/dotc/core')
-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
4 files changed, 7 insertions, 4 deletions
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