Scala Library: scala.reflect
scala.reflect
object ClassManifestFactory
ClassManifestFactory
defines factory methods for manifests. It is intended
for use by the compiler and should not be used in client code.
Unlike ClassManifest
, this factory isn’t annotated with a deprecation
warning. This is done to prevent avalanches of deprecation warnings in the code
that calls methods with manifests.
In a perfect world, we would just remove the @deprecated annotation from
ClassManifest
the object and then delete it in 2.11. After all, that object
is explicitly marked as internal, so noone should use it. However a lot of
existing libraries disregarded the scaladoc that comes with ClassManifest
, so
we need to somehow nudge them into migrating prior to removing stuff out of the
blue. Hence we’ve introduced this design decision as the lesser of two evils.
object ClassTag extends Serializable
Class tags corresponding to primitive types and constructor/extractor for ClassTags.
object ManifestFactory
ManifestFactory
defines factory methods for manifests. It is intended for use
by the compiler and should not be used in client code.
Unlike Manifest
, this factory isn’t annotated with a deprecation warning.
This is done to prevent avalanches of deprecation warnings in the code that
calls methods with manifests. Why so complicated? Read up the comments for
ClassManifestFactory
.
object NameTransformer
Provides functions to encode and decode Scala symbolic names. Also provides some constants.
object NoManifest extends OptManifest[Nothing] with Serializable
One of the branches of an scala.reflect.OptManifest.
Type Members
abstract class AnyValManifest[T <: AnyVal] extends Manifest[T] with Equals
- Annotations
- @ SerialVersionUID ()
- Source
type ClassManifest[T] = ClassTag[T]
A ClassManifest[T]
is an opaque descriptor for type T
.
trait ClassManifestDeprecatedApis[T] extends OptManifest[T]
- Self Type
- ClassManifest [T]
- Annotations
- @ deprecated
- Deprecated
- (Since version 2.10.0) Use scala.reflect.ClassTag instead
- Source
trait ClassTag[T] extends ClassManifestDeprecatedApis[T] with Equals with Serializable
A ClassTag[T]
stores the erased class of a given type T
, accessible via the
runtimeClass
field. This is particularly useful for instantiating Array
s
whose element types are unknown at compile time.
ClassTag
s are a weaker special case of scala.reflect.api.TypeTags#TypeTag s,
in that they wrap only the runtime class of a given type, whereas a TypeTag
contains all static type information. That is, ClassTag
s are constructed from
knowing only the top-level class of a type, without necessarily knowing all of
its argument types. This runtime information is enough for runtime Array
creation.
For example:
See scala.reflect.api.TypeTags for more examples, or the Reflection Guide: TypeTags for more details.
- Annotations
- @ implicitNotFound (msg = “No ClassTag available for ${T}”)
- Source
trait Manifest[T] extends ClassManifest[T] with Equals
A Manifest[T]
is an opaque descriptor for type T. Its supported use is to give
access to the erasure of the type as a Class
instance, as is necessary for the
creation of native Arrays
if the class is not known at compile time.
The type-relation operators <:<
and =:=
should be considered approximations
only, as there are numerous aspects of type conformance which are not yet
adequately represented in manifests.
Example usages:
- Annotations
- @ implicitNotFound (msg = “No Manifest available for ${T}.”)
- Source
trait OptManifest[+T] extends Serializable
A OptManifest[T]
is an optional scala.reflect.Manifest.
It is either a Manifest
or the value NoManifest
.
Full Source:
Interested in Scala?
I send out weekly, personalized emails with articles and conference talks.
Subscribe now.