diff options
author | Paul Phillips <paulp@improving.org> | 2010-12-05 02:56:08 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-12-05 02:56:08 +0000 |
commit | 77eb8fefec3e62ead95c7d409ec5a28f30289ec3 (patch) | |
tree | 5e035714a7e6363d1ae7f712d5b1f73c1d27d79e /src/library/scala/util/control | |
parent | 626e38940b72f5e8445ecbece4d41996b5e2842e (diff) | |
download | scala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.tar.gz scala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.tar.bz2 scala-77eb8fefec3e62ead95c7d409ec5a28f30289ec3.zip |
Mopping up after the deprecation of exit and er...
Mopping up after the deprecation of exit and error. It is decidedly
non-trivial (at least for the IDE-impaired) to be completely sure of
which error function was being called when there were about twenty with
the same signature in trunk and they are being variously inherited,
imported, shadowed, etc. So although I was careful, the possibility
exists that something is now calling a different "error" function than
before. Caveat programmer.
(And let's all make it our policy not to name anything "error" or "exit"
from here on out....) No review.
Diffstat (limited to 'src/library/scala/util/control')
-rw-r--r-- | src/library/scala/util/control/Exception.scala | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala index 3ad5b30f7b..ad90b222c2 100644 --- a/src/library/scala/util/control/Exception.scala +++ b/src/library/scala/util/control/Exception.scala @@ -23,16 +23,17 @@ import java.lang.reflect.InvocationTargetException object Exception { type Catcher[+T] = PartialFunction[Throwable, T] - def mkCatcher[Ex <: Throwable, T](isDef: Ex => Boolean, f: Ex => T) = new Catcher[T] { + def mkCatcher[Ex <: Throwable: ClassManifest, T](isDef: Ex => Boolean, f: Ex => T) = new Catcher[T] { private def downcast(x: Throwable): Option[Ex] = - if (x.isInstanceOf[Ex]) Some(x.asInstanceOf[Ex]) else None + if (classManifest[Ex].erasure.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[Ex]) + else None def isDefinedAt(x: Throwable) = downcast(x) exists isDef def apply(x: Throwable): T = f(downcast(x).get) } def mkThrowableCatcher[T](isDef: Throwable => Boolean, f: Throwable => T) = mkCatcher(isDef, f) - implicit def throwableSubtypeToCatcher[Ex <: Throwable, T](pf: PartialFunction[Ex, T]) = + implicit def throwableSubtypeToCatcher[Ex <: Throwable: ClassManifest, T](pf: PartialFunction[Ex, T]) = mkCatcher(pf.isDefinedAt _, pf.apply _) /** !!! Not at all sure of every factor which goes into this, |