diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-06-26 11:00:26 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-07-02 11:44:50 +0200 |
commit | cba0cbb892e991a0946270d1a7da63993f248225 (patch) | |
tree | 47583676e4f3e7ad9e0288a373ee9fd9ac4d2cc4 /src/library/scala/reflect/ClassTag.scala | |
parent | d14d8178fa39961951d7dd74a37994db86a13063 (diff) | |
download | scala-cba0cbb892e991a0946270d1a7da63993f248225.tar.gz scala-cba0cbb892e991a0946270d1a7da63993f248225.tar.bz2 scala-cba0cbb892e991a0946270d1a7da63993f248225.zip |
Improves backward compatibility of manifests
1) type ClassManifest[T] = ClassTag[T] (solves a problem
with toArray[T: ClassManifest] defined on most of the collections;
if these types weren't aliases, then we won't be able to change
the signature of that method to toArray[T: ClassTag], because
that would break source compatibility for those who override
toArray in their custom collections)
2) Compiler-generated manifests no longer trigger deprecation warnings
(this is implemented by using ClassManifestFactory instead of ClassManifest
and ManifestFactory instead of Manifest)
3) Deprecation messages got improved to reflect the changes
that were introduced in 2.10.0-M4.
Diffstat (limited to 'src/library/scala/reflect/ClassTag.scala')
-rw-r--r-- | src/library/scala/reflect/ClassTag.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/library/scala/reflect/ClassTag.scala b/src/library/scala/reflect/ClassTag.scala index 860e7bac28..eb63defeb3 100644 --- a/src/library/scala/reflect/ClassTag.scala +++ b/src/library/scala/reflect/ClassTag.scala @@ -19,18 +19,20 @@ import scala.runtime.ScalaRunTime.arrayClass * @see [[scala.reflect.base.TypeTags]] */ @annotation.implicitNotFound(msg = "No ClassTag available for ${T}") -trait ClassTag[T] extends Equals with Serializable { +trait ClassTag[T] extends ClassManifestDeprecatedApis[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 a runtime class of type `T` */ + /** A class representing the type `U` to which `T` would be erased. + * Note that there is no subtyping relationship between `T` and `U`. + */ def runtimeClass: jClass[_] /** Produces a `ClassTag` that knows how to build `Array[Array[T]]` */ 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] = + override def newArray(len: Int): Array[T] = 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]] |