diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-07-30 12:47:50 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-07-30 12:51:09 +0200 |
commit | a5aa050a25886597f72f79dd84e43d21d76a6c36 (patch) | |
tree | 0a5811712463d405ecae1aa0fed09836655865fe /src | |
parent | 1ad6e501997d332e2bc0ccc8dd40e3909e728930 (diff) | |
download | scala-a5aa050a25886597f72f79dd84e43d21d76a6c36.tar.gz scala-a5aa050a25886597f72f79dd84e43d21d76a6c36.tar.bz2 scala-a5aa050a25886597f72f79dd84e43d21d76a6c36.zip |
ClassTag.Nothing now throws an exception
Nothing is a bottom type, so it doesn't make much sense for it to have
a meaningful erasure (ClassTag.Nothing.runtimeClass).
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/reflect/ClassTag.scala | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 5255c44f10..7b6df6e31c 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -64,7 +64,6 @@ trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serial } object ClassTag { - private val NothingTYPE = classOf[scala.runtime.Nothing$] private val NullTYPE = classOf[scala.runtime.Null$] private val ObjectTYPE = classOf[java.lang.Object] @@ -81,7 +80,13 @@ object ClassTag { val Object : ClassTag[java.lang.Object] = new ClassTag[java.lang.Object]{ def runtimeClass = ObjectTYPE; private def readResolve() = ClassTag.Object } val AnyVal : ClassTag[scala.AnyVal] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyVal]] val AnyRef : ClassTag[scala.AnyRef] = ClassTag.Object.asInstanceOf[ClassTag[scala.AnyRef]] - val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ def runtimeClass = NothingTYPE; private def readResolve() = ClassTag.Nothing } + val Nothing : ClassTag[scala.Nothing] = new ClassTag[scala.Nothing]{ + def runtimeClass = throw new Exception("Nothing is a bottom type, therefore its erasure does not return a value") + private def readResolve() = ClassTag.Nothing + override def equals(x: Any) = x.isInstanceOf[ClassTag[_]] && (x.asInstanceOf[AnyRef] eq ClassTag.Nothing) + override def hashCode = System.identityHashCode(this) + override def toString = "ClassTag[Nothing]" + } val Null : ClassTag[scala.Null] = new ClassTag[scala.Null]{ def runtimeClass = NullTYPE; private def readResolve() = ClassTag.Null } def apply[T](runtimeClass1: jClass[_]): ClassTag[T] = |