diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-06-06 09:43:05 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-06-08 15:31:45 +0200 |
commit | 252a44864786b6832b9da4c29d1ac9aad48c4291 (patch) | |
tree | aef048d8a210d38f116b8875d99e3c13c703d685 /src/library | |
parent | 6bb5975289c5b11cb8c88dd4629286956b5d3d27 (diff) | |
download | scala-252a44864786b6832b9da4c29d1ac9aad48c4291.tar.gz scala-252a44864786b6832b9da4c29d1ac9aad48c4291.tar.bz2 scala-252a44864786b6832b9da4c29d1ac9aad48c4291.zip |
ClassTag.erasure => ClassTag.runtimeClass
This change is made to be consistent with JavaMirrors.
And, in my opinion, a technology-neutral term is better here.
Diffstat (limited to 'src/library')
-rw-r--r-- | src/library/scala/collection/mutable/ArrayBuilder.scala | 4 | ||||
-rw-r--r-- | src/library/scala/collection/mutable/WrappedArrayBuilder.scala | 4 | ||||
-rw-r--r-- | src/library/scala/collection/parallel/ParIterableLike.scala | 2 | ||||
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 2 | ||||
-rw-r--r-- | src/library/scala/reflect/ArrayTag.scala | 4 | ||||
-rw-r--r-- | src/library/scala/reflect/ClassManifest.scala | 1 | ||||
-rw-r--r-- | src/library/scala/reflect/ClassTag.scala | 60 | ||||
-rw-r--r-- | src/library/scala/reflect/base/Attachments.scala | 4 | ||||
-rw-r--r-- | src/library/scala/reflect/base/TagInterop.scala | 8 | ||||
-rw-r--r-- | src/library/scala/reflect/base/TypeTags.scala | 4 | ||||
-rw-r--r-- | src/library/scala/reflect/makro/Reifiers.scala | 6 | ||||
-rw-r--r-- | src/library/scala/runtime/ScalaRunTime.scala | 4 | ||||
-rw-r--r-- | src/library/scala/util/Marshal.scala | 2 | ||||
-rw-r--r-- | src/library/scala/util/control/Exception.scala | 2 |
14 files changed, 54 insertions, 53 deletions
diff --git a/src/library/scala/collection/mutable/ArrayBuilder.scala b/src/library/scala/collection/mutable/ArrayBuilder.scala index 293e85a97e..ff69778772 100644 --- a/src/library/scala/collection/mutable/ArrayBuilder.scala +++ b/src/library/scala/collection/mutable/ArrayBuilder.scala @@ -36,8 +36,8 @@ object ArrayBuilder { */ def make[T: ArrayTag](): ArrayBuilder[T] = { val tag = implicitly[ArrayTag[T]] - val erasure = ScalaRunTime.arrayElementClass(tag) - erasure match { + val runtimeClass = ScalaRunTime.arrayElementClass(tag) + runtimeClass match { case java.lang.Byte.TYPE => new ArrayBuilder.ofByte().asInstanceOf[ArrayBuilder[T]] case java.lang.Short.TYPE => new ArrayBuilder.ofShort().asInstanceOf[ArrayBuilder[T]] case java.lang.Character.TYPE => new ArrayBuilder.ofChar().asInstanceOf[ArrayBuilder[T]] diff --git a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala index 99a0b0ede3..abd46500fa 100644 --- a/src/library/scala/collection/mutable/WrappedArrayBuilder.scala +++ b/src/library/scala/collection/mutable/WrappedArrayBuilder.scala @@ -32,8 +32,8 @@ class WrappedArrayBuilder[A](tag: ArrayTag[A]) extends Builder[A, WrappedArray[A private var size: Int = 0 private def mkArray(size: Int): WrappedArray[A] = { - val erasure = arrayElementClass(tag) - val newelems = erasure match { + val runtimeClass = arrayElementClass(tag) + val newelems = runtimeClass match { case java.lang.Byte.TYPE => new WrappedArray.ofByte(new Array[Byte](size)).asInstanceOf[WrappedArray[A]] case java.lang.Short.TYPE => new WrappedArray.ofShort(new Array[Short](size)).asInstanceOf[WrappedArray[A]] case java.lang.Character.TYPE => new WrappedArray.ofChar(new Array[Char](size)).asInstanceOf[WrappedArray[A]] diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index 321f259f5d..c1d0e9c3a6 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -303,7 +303,7 @@ self: ParIterableLike[T, Repr, Sequential] => protected implicit def builder2ops[Elem, To](cb: Builder[Elem, To]) = new BuilderOps[Elem, To] { def ifIs[Cmb](isbody: Cmb => Unit) = new Otherwise[Cmb] { def otherwise(notbody: => Unit)(implicit t: ClassTag[Cmb]) { - if (cb.getClass == t.erasure) isbody(cb.asInstanceOf[Cmb]) else notbody + if (cb.getClass == t.runtimeClass) isbody(cb.asInstanceOf[Cmb]) else notbody } } def isCombiner = cb.isInstanceOf[Combiner[_, _]] diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index c42393eee2..375659bedc 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -489,7 +489,7 @@ trait Future[+T] extends Awaitable[T] { case l: Left[_, _] => p complete l.asInstanceOf[Left[Throwable, S]] case Right(t) => p complete (try { - Right(boxedType(tag.erasure).cast(t).asInstanceOf[S]) + Right(boxedType(tag.runtimeClass).cast(t).asInstanceOf[S]) } catch { case e: ClassCastException => Left(e) }) diff --git a/src/library/scala/reflect/ArrayTag.scala b/src/library/scala/reflect/ArrayTag.scala index 3eba901f4f..0dc25c8dc2 100644 --- a/src/library/scala/reflect/ArrayTag.scala +++ b/src/library/scala/reflect/ArrayTag.scala @@ -7,8 +7,8 @@ package scala.reflect * cannot contain unresolved references to type parameters or abstract types. * * Scala library provides a standard implementation of this trait, - * `ClassTag[T]` that explicitly carries the `java.lang.Class` erasure of type T - * and uses Java reflection to instantiate arrays. + * `ClassTag[T]` that explicitly carries the runtime class of type T + * and uses reflection to instantiate arrays. * * However other platforms (e.g. a Scala -> JS crosscompiler) may reimplement this trait as they see fit * and then expose the implementation via an implicit macro. diff --git a/src/library/scala/reflect/ClassManifest.scala b/src/library/scala/reflect/ClassManifest.scala index 43e043fd40..d89d31f689 100644 --- a/src/library/scala/reflect/ClassManifest.scala +++ b/src/library/scala/reflect/ClassManifest.scala @@ -27,6 +27,7 @@ trait ClassManifest[T] extends OptManifest[T] with ClassTag[T] with Equals with /** A class representing the type `U` to which `T` would be erased. Note * that there is no subtyping relationship between `T` and `U`. */ def erasure: jClass[_] + override def runtimeClass: jClass[_] = erasure private def subtype(sub: jClass[_], sup: jClass[_]): Boolean = { def loop(left: Set[jClass[_]], seen: Set[jClass[_]]): Boolean = { diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index ec66a42730..11fa4c8dc7 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -4,7 +4,7 @@ import java.lang.{ Class => jClass } import language.{implicitConversions, existentials} import scala.runtime.ScalaRunTime.arrayClass -/** A `ClassTag[T]` wraps a Java class, which can be accessed via the `erasure` method. +/** A `ClassTag[T]` wraps a runtime class, which can be accessed via the `runtimeClass` method. * * This is useful in itself, but also enables very important use case. * Having this knowledge ClassTag can instantiate `Arrays` @@ -12,7 +12,7 @@ import scala.runtime.ScalaRunTime.arrayClass * Hence, ClassTag[T] conforms to the ArrayTag[T] trait. * * If an implicit value of type u.ClassTag[T] is required, the compiler will make one up on demand. - * The implicitly created value contains in its erasure field the Java class that is the result of erasing type T. + * The implicitly created value contains in its `runtimeClass` field the runtime class that is the result of erasing type T. * In that value, any occurrences of type parameters or abstract types U which come themselves with a ClassTag * or a reflect.mirror.ConcreteTypeTag are represented by the type referenced by that tag. * If the type T contains unresolved references to type parameters or abstract types, a static error results. @@ -27,15 +27,15 @@ trait ClassTag[T] extends ArrayTag[T] with Equals with Serializable { // please, don't add any APIs here, like it was with `newWrappedArray` and `newArrayBuilder` // class tags, and all tags in general, should be as minimalistic as possible - /** Returns an erasure of type `T` */ - def erasure: jClass[_] + /** Returns a runtime class of type `T` */ + def runtimeClass: jClass[_] /** Produces a `ClassTag` that knows how to build `Array[Array[T]]` */ - def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](arrayClass(erasure)) + def wrap: ClassTag[Array[T]] = ClassTag[Array[T]](arrayClass(runtimeClass)) /** Produces a new array with element type `T` and length `len` */ def newArray(len: Int): Array[T] = - erasure match { + runtimeClass match { case java.lang.Byte.TYPE => new Array[Byte](len).asInstanceOf[Array[T]] case java.lang.Short.TYPE => new Array[Short](len).asInstanceOf[Array[T]] case java.lang.Character.TYPE => new Array[Char](len).asInstanceOf[Array[T]] @@ -45,14 +45,14 @@ trait ClassTag[T] extends ArrayTag[T] with Equals with Serializable { case java.lang.Double.TYPE => new Array[Double](len).asInstanceOf[Array[T]] case java.lang.Boolean.TYPE => new Array[Boolean](len).asInstanceOf[Array[T]] case java.lang.Void.TYPE => new Array[Unit](len).asInstanceOf[Array[T]] - case _ => java.lang.reflect.Array.newInstance(erasure, len).asInstanceOf[Array[T]] + case _ => java.lang.reflect.Array.newInstance(runtimeClass, len).asInstanceOf[Array[T]] } /** case class accessories */ override def canEqual(x: Any) = x.isInstanceOf[ClassTag[_]] - override def equals(x: Any) = x.isInstanceOf[ClassTag[_]] && this.erasure == x.asInstanceOf[ClassTag[_]].erasure - override def hashCode = scala.runtime.ScalaRunTime.hash(erasure) - override def toString = "ClassTag[" + erasure + "]" + override def equals(x: Any) = x.isInstanceOf[ClassTag[_]] && this.runtimeClass == x.asInstanceOf[ClassTag[_]].runtimeClass + override def hashCode = scala.runtime.ScalaRunTime.hash(runtimeClass) + override def toString = "ClassTag[" + runtimeClass + "]" } object ClassTag { @@ -61,25 +61,25 @@ object ClassTag { private val ObjectTYPE = classOf[java.lang.Object] private val StringTYPE = classOf[java.lang.String] - val Byte : ClassTag[scala.Byte] = new ClassTag[scala.Byte]{ def erasure = java.lang.Byte.TYPE; private def readResolve() = ClassTag.Byte } - val Short : ClassTag[scala.Short] = new ClassTag[scala.Short]{ def erasure = java.lang.Short.TYPE; private def readResolve() = ClassTag.Short } - val Char : ClassTag[scala.Char] = new ClassTag[scala.Char]{ def erasure = java.lang.Character.TYPE; private def readResolve() = ClassTag.Char } - val Int : ClassTag[scala.Int] = new ClassTag[scala.Int]{ def erasure = java.lang.Integer.TYPE; private def readResolve() = ClassTag.Int } - val Long : ClassTag[scala.Long] = new ClassTag[scala.Long]{ def erasure = java.lang.Long.TYPE; private def readResolve() = ClassTag.Long } - val Float : ClassTag[scala.Float] = new ClassTag[scala.Float]{ def erasure = java.lang.Float.TYPE; private def readResolve() = ClassTag.Float } - val Double : ClassTag[scala.Double] = new ClassTag[scala.Double]{ def erasure = java.lang.Double.TYPE; private def readResolve() = ClassTag.Double } - val Boolean : ClassTag[scala.Boolean] = new ClassTag[scala.Boolean]{ def erasure = java.lang.Boolean.TYPE; private def readResolve() = ClassTag.Boolean } - val Unit : ClassTag[scala.Unit] = new ClassTag[scala.Unit]{ def erasure = java.lang.Void.TYPE; private def readResolve() = ClassTag.Unit } - val Any : ClassTag[scala.Any] = new ClassTag[scala.Any]{ def erasure = ObjectTYPE; private def readResolve() = ClassTag.Any } - val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def erasure = ObjectTYPE; private def readResolve() = ClassTag.Object } - val AnyVal : ClassTag[scala.AnyVal] = new ClassTag[scala.AnyVal]{ def erasure = ObjectTYPE; private def readResolve() = ClassTag.AnyVal } - val AnyRef : ClassTag[scala.AnyRef] = new ClassTag[scala.AnyRef]{ def erasure = ObjectTYPE; private def readResolve() = ClassTag.AnyRef } - val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def erasure = NothingTYPE; private def readResolve() = ClassTag.Nothing } - val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def erasure = NullTYPE; private def readResolve() = ClassTag.Null } - val String : ClassTag[java.lang.String] = new ClassTag[java.lang.String]{ def erasure = StringTYPE; private def readResolve() = ClassTag.String } + val Byte : ClassTag[scala.Byte] = new ClassTag[scala.Byte]{ def runtimeClass = java.lang.Byte.TYPE; private def readResolve() = ClassTag.Byte } + val Short : ClassTag[scala.Short] = new ClassTag[scala.Short]{ def runtimeClass = java.lang.Short.TYPE; private def readResolve() = ClassTag.Short } + val Char : ClassTag[scala.Char] = new ClassTag[scala.Char]{ def runtimeClass = java.lang.Character.TYPE; private def readResolve() = ClassTag.Char } + val Int : ClassTag[scala.Int] = new ClassTag[scala.Int]{ def runtimeClass = java.lang.Integer.TYPE; private def readResolve() = ClassTag.Int } + val Long : ClassTag[scala.Long] = new ClassTag[scala.Long]{ def runtimeClass = java.lang.Long.TYPE; private def readResolve() = ClassTag.Long } + val Float : ClassTag[scala.Float] = new ClassTag[scala.Float]{ def runtimeClass = java.lang.Float.TYPE; private def readResolve() = ClassTag.Float } + val Double : ClassTag[scala.Double] = new ClassTag[scala.Double]{ def runtimeClass = java.lang.Double.TYPE; private def readResolve() = ClassTag.Double } + val Boolean : ClassTag[scala.Boolean] = new ClassTag[scala.Boolean]{ def runtimeClass = java.lang.Boolean.TYPE; private def readResolve() = ClassTag.Boolean } + val Unit : ClassTag[scala.Unit] = new ClassTag[scala.Unit]{ def runtimeClass = java.lang.Void.TYPE; private def readResolve() = ClassTag.Unit } + val Any : ClassTag[scala.Any] = new ClassTag[scala.Any]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Any } + val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Object } + val AnyVal : ClassTag[scala.AnyVal] = new ClassTag[scala.AnyVal]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.AnyVal } + val AnyRef : ClassTag[scala.AnyRef] = new ClassTag[scala.AnyRef]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.AnyRef } + val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def runtimeClass = NothingTYPE; private def readResolve() = ClassTag.Nothing } + val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def runtimeClass = NullTYPE; private def readResolve() = ClassTag.Null } + val String : ClassTag[java.lang.String] = new ClassTag[java.lang.String]{ def runtimeClass = StringTYPE; private def readResolve() = ClassTag.String } - def apply[T](erasure1: jClass[_]): ClassTag[T] = - erasure1 match { + def apply[T](runtimeClass1: jClass[_]): ClassTag[T] = + runtimeClass1 match { case java.lang.Byte.TYPE => ClassTag.Byte.asInstanceOf[ClassTag[T]] case java.lang.Short.TYPE => ClassTag.Short.asInstanceOf[ClassTag[T]] case java.lang.Character.TYPE => ClassTag.Char.asInstanceOf[ClassTag[T]] @@ -91,8 +91,8 @@ object ClassTag { case java.lang.Void.TYPE => ClassTag.Unit.asInstanceOf[ClassTag[T]] case ObjectTYPE => ClassTag.Object.asInstanceOf[ClassTag[T]] case StringTYPE => ClassTag.String.asInstanceOf[ClassTag[T]] - case _ => new ClassTag[T]{ def erasure = erasure1 } + case _ => new ClassTag[T]{ def runtimeClass = runtimeClass1 } } - def unapply[T](ctag: ClassTag[T]): Option[Class[_]] = Some(ctag.erasure) + def unapply[T](ctag: ClassTag[T]): Option[Class[_]] = Some(ctag.runtimeClass) }
\ No newline at end of file diff --git a/src/library/scala/reflect/base/Attachments.scala b/src/library/scala/reflect/base/Attachments.scala index 76606ca958..43e870fc4f 100644 --- a/src/library/scala/reflect/base/Attachments.scala +++ b/src/library/scala/reflect/base/Attachments.scala @@ -21,14 +21,14 @@ abstract class Attachments { self => def all: Set[Any] = Set.empty def get[T: ClassTag]: Option[T] = - (all find (_.getClass == classTag[T].erasure)).asInstanceOf[Option[T]] + (all find (_.getClass == classTag[T].runtimeClass)).asInstanceOf[Option[T]] /** Creates a copy of this attachment with its payload updated */ def add(attachment: Any): Attachments { type Pos = self.Pos } = new NonemptyAttachments(this.pos, all + attachment) def remove[T: ClassTag]: Attachments { type Pos = self.Pos } = { - val newAll = all filterNot (_.getClass == classTag[T].erasure) + val newAll = all filterNot (_.getClass == classTag[T].runtimeClass) if (newAll.isEmpty) pos.asInstanceOf[Attachments { type Pos = self.Pos }] else new NonemptyAttachments(this.pos, newAll) } diff --git a/src/library/scala/reflect/base/TagInterop.scala b/src/library/scala/reflect/base/TagInterop.scala index 0ec4d06a6c..4315341630 100644 --- a/src/library/scala/reflect/base/TagInterop.scala +++ b/src/library/scala/reflect/base/TagInterop.scala @@ -5,13 +5,13 @@ import scala.runtime.ScalaRunTime._ trait TagInterop { self: Universe => def arrayTagToClassManifest[T](tag: ArrayTag[T]): ClassManifest[T] = { - val erasure = arrayElementClass(tag) - if (erasure.isArray) { - val elementClass = arrayElementClass(erasure) + val runtimeClass = arrayElementClass(tag) + if (runtimeClass.isArray) { + val elementClass = arrayElementClass(runtimeClass) val elementManifest = arrayTagToClassManifest(ClassTag(elementClass)) ClassManifest.arrayType(elementManifest).asInstanceOf[ClassManifest[T]] } else { - ClassManifest.fromClass(erasure.asInstanceOf[Class[T]]) + ClassManifest.fromClass(runtimeClass.asInstanceOf[Class[T]]) } } diff --git a/src/library/scala/reflect/base/TypeTags.scala b/src/library/scala/reflect/base/TypeTags.scala index 5c55f45cf7..8d4aa04efc 100644 --- a/src/library/scala/reflect/base/TypeTags.scala +++ b/src/library/scala/reflect/base/TypeTags.scala @@ -21,7 +21,7 @@ import language.implicitConversions * [[scala.reflect.base.Universe#TypeTag]] and [[scala.reflect.base.Universe#ConcreteTypeTag]]. * * An [[scala.reflect.ArrayTag]] value carries knowledge about how to build an array of elements of type T. - * Typically such operation is performed by storing an erasure and instantiating arrays via reflection, + * Typically such operation is performed by storing a runtime class and instantiating arrays via reflection, * but [[scala.reflect.ArrayTag]] only defines an interface, not an implementation, hence it only contains the factory methods * `newArray` and `wrap` that can be used to build, correspondingly, single-dimensional and multi-dimensional arrays. * @@ -35,7 +35,7 @@ import language.implicitConversions * * It is recommended to use the tag supertypes of to precisely express your intent, i.e.: * use ArrayTag when you just want to construct arrays, - * use ClassTag only when you need an erasure, e.g. for serialization or pattern matching. + * use ClassTag only when you need a runtime class, e.g. for serialization or pattern matching. * * [Eugene++] also mention sensitivity to prefixes, i.e. that rb.TypeTag is different from ru.TypeTag * [Eugene++] migratability between mirrors and universes is also worth mentioning diff --git a/src/library/scala/reflect/makro/Reifiers.scala b/src/library/scala/reflect/makro/Reifiers.scala index 0e0a4a765e..427b68f2d7 100644 --- a/src/library/scala/reflect/makro/Reifiers.scala +++ b/src/library/scala/reflect/makro/Reifiers.scala @@ -48,10 +48,10 @@ trait Reifiers { */ def reifyType(prefix: Tree, tpe: Type, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): Tree - /** Given a type, generate a tree that when compiled and executed produces the erasure of the original type. - * If ``concrete'' is true, then this function will bail on types, whose erasure includes abstract types (like `ClassTag` does). + /** Given a type, generate a tree that when compiled and executed produces the runtime class of the original type. + * If ``concrete'' is true, then this function will bail on types, who refer to abstract types (like `ClassTag` does). */ - def reifyErasure(tpe: Type, concrete: Boolean = true): Tree + def reifyRuntimeClass(tpe: Type, concrete: Boolean = true): Tree /** Undoes reification of a tree. * diff --git a/src/library/scala/runtime/ScalaRunTime.scala b/src/library/scala/runtime/ScalaRunTime.scala index 5cd301a0fe..e3d3c89aa6 100644 --- a/src/library/scala/runtime/ScalaRunTime.scala +++ b/src/library/scala/runtime/ScalaRunTime.scala @@ -59,7 +59,7 @@ object ScalaRunTime { */ def arrayElementClass(schematic: Any): Class[_] = schematic match { case cls: Class[_] => cls.getComponentType - case tag: ClassTag[_] => tag.erasure + case tag: ClassTag[_] => tag.runtimeClass case tag: ArrayTag[_] => tag.newArray(0).getClass.getComponentType case _ => throw new UnsupportedOperationException("unsupported schematic %s (%s)".format(schematic, if (schematic == null) "null" else schematic.getClass)) } @@ -69,7 +69,7 @@ object ScalaRunTime { * rewrites expressions like 5.getClass to come here. */ def anyValClass[T <: AnyVal : ClassTag](value: T): Class[T] = - classTag[T].erasure.asInstanceOf[Class[T]] + classTag[T].runtimeClass.asInstanceOf[Class[T]] /** Retrieve generic array element */ def array_apply(xs: AnyRef, idx: Int): Any = xs match { diff --git a/src/library/scala/util/Marshal.scala b/src/library/scala/util/Marshal.scala index 209cd6c062..2d3f54a95e 100644 --- a/src/library/scala/util/Marshal.scala +++ b/src/library/scala/util/Marshal.scala @@ -39,7 +39,7 @@ object Marshal { try { // [Eugene] needs review // previously was: found <:< expected - found.erasure.asSubclass(expected.erasure) + found.runtimeClass.asSubclass(expected.runtimeClass) in.readObject.asInstanceOf[A] } catch { case _: ClassCastException => diff --git a/src/library/scala/util/control/Exception.scala b/src/library/scala/util/control/Exception.scala index 38f4abb20a..466118f85b 100644 --- a/src/library/scala/util/control/Exception.scala +++ b/src/library/scala/util/control/Exception.scala @@ -32,7 +32,7 @@ object Exception { def mkCatcher[Ex <: Throwable: ClassTag, T](isDef: Ex => Boolean, f: Ex => T) = new Catcher[T] { private def downcast(x: Throwable): Option[Ex] = - if (classTag[Ex].erasure.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[Ex]) + if (classTag[Ex].runtimeClass.isAssignableFrom(x.getClass)) Some(x.asInstanceOf[Ex]) else None def isDefinedAt(x: Throwable) = downcast(x) exists isDef |