scala.reflect

package scala.reflect

Members list

Type members

Classlikes

abstract class AnyValManifest[T <: AnyVal](val toString: String) extends Manifest[T], Equals

Attributes

Source
Manifest.scala
Supertypes
trait Manifest[T]
trait ClassTag[T]
trait Equals
trait OptManifest[T]
trait Serializable
class Object
trait Matchable
class Any
Show all

ClassManifestFactory defines factory methods for manifests.

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 no one 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.

Attributes

Source
ClassManifestDeprecatedApis.scala
Supertypes
class Object
trait Matchable
class Any
Self type

A ClassTag[T] stores the erased class of a given type T, accessible via the runtimeClass field.

A ClassTag[T] stores the erased class of a given type T, accessible via the runtimeClass field. This is particularly useful for instantiating Arrays whose element types are unknown at compile time.

ClassTags are a weaker special case of scala.reflect.api.TypeTags.TypeTags, in that they wrap only the runtime class of a given type, whereas a TypeTag contains all static type information. That is, ClassTags 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:

scala> def mkArray[T : ClassTag](elems: T*) = Array[T](elems: _*)
mkArray: [T](elems: T*)(implicit evidence$1: scala.reflect.ClassTag[T])Array[T]

scala> mkArray(42, 13)
res0: Array[Int] = Array(42, 13)

scala> mkArray("Japan","Brazil","Germany")
res1: Array[String] = Array(Japan, Brazil, Germany)

See scala.reflect.api.TypeTags for more examples, or the Reflection Guide: TypeTags for more details.

Attributes

Companion
object
Source
ClassTag.scala
Supertypes
trait Equals
trait OptManifest[T]
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
trait Manifest[T]
class AnyValManifest[T]
object ClassTag

Class tags corresponding to primitive types and constructor/extractor for ClassTags.

Class tags corresponding to primitive types and constructor/extractor for ClassTags.

Attributes

Companion
trait
Source
ClassTag.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
ClassTag.type
trait Enum extends Product, Serializable

A base trait of all Scala enum definitions

A base trait of all Scala enum definitions

Attributes

Source
Enum.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Any
trait Manifest[T] extends ClassTag[T], Equals

A Manifest[T] is an opaque descriptor for type T.

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:

def arr[T] = new Array[T](0)                          // does not compile
def arr[T](implicit m: Manifest[T]) = new Array[T](0) // compiles
def arr[T: Manifest] = new Array[T](0)                // shorthand for the preceding

// Methods manifest and optManifest are in [[scala.Predef]].
def isApproxSubType[T: Manifest, U: Manifest] = manifest[T] <:< manifest[U]
isApproxSubType[List[String], List[AnyRef]] // true
isApproxSubType[List[String], List[Int]]    // false

def methods[T: Manifest] = manifest[T].runtimeClass.getMethods
def retType[T: Manifest](name: String) =
  methods[T] find (_.getName == name) map (_.getGenericReturnType)

retType[Map[_, _]]("values")  // Some(scala.collection.Iterable<B>)

Attributes

Companion
object
Source
Manifest.scala
Supertypes
trait ClassTag[T]
trait Equals
trait OptManifest[T]
trait Serializable
class Object
trait Matchable
class Any
Show all
Known subtypes
class AnyValManifest[T]
object Manifest

The object Manifest defines factory methods for manifests.

The object Manifest defines factory methods for manifests. It is intended for use by the compiler and should not be used in client code.

Attributes

Companion
trait
Source
Manifest.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
Manifest.type

ManifestFactory defines factory methods for manifests.

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.

Attributes

Source
Manifest.scala
Supertypes
class Object
trait Matchable
class Any
Self type

Provides functions to encode and decode Scala symbolic names.

Provides functions to encode and decode Scala symbolic names. Also provides some constants.

Attributes

Source
NameTransformer.scala
Supertypes
class Object
trait Matchable
class Any
Self type

One of the branches of an scala.reflect.OptManifest.

One of the branches of an scala.reflect.OptManifest.

Attributes

Source
NoManifest.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Self type
NoManifest.type
trait OptManifest[+T] extends Serializable

A OptManifest[T] is an optional scala.reflect.Manifest.

A OptManifest[T] is an optional scala.reflect.Manifest.

It is either a Manifest or the value NoManifest.

Attributes

Source
OptManifest.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
trait ClassTag[T]
trait Manifest[T]
class AnyValManifest[T]
object NoManifest
trait Selectable extends Selectable

A class that implements structural selections using Java reflection.

A class that implements structural selections using Java reflection.

It can be used as a supertrait of a class or be made available as an implicit conversion via reflectiveSelectable.

In Scala.js, it is implemented using a separate Scala.js-specific mechanism, since Java reflection is not available.

Attributes

Companion
object
Source
Selectable.scala
Supertypes
trait Selectable
class Object
trait Matchable
class Any
object Selectable

Attributes

Companion
trait
Source
Selectable.scala
Supertypes
class Object
trait Matchable
class Any
Self type
Selectable.type
trait TypeTest[-S, T] extends Serializable

A TypeTest[S, T] contains the logic needed to know at runtime if a value of type S is an instance of T.

A TypeTest[S, T] contains the logic needed to know at runtime if a value of type S is an instance of T.

If a pattern match is performed on a term of type s: S that is uncheckable with s.isInstanceOf[T] and the pattern is one of the following forms:

  • t: T
  • t @ X() where X.unapply takes an argument of type T then a given instance of TypeTest[S, T] is summoned and used to perform the test.

Attributes

Companion
object
Source
TypeTest.scala
Supertypes
trait Serializable
class Object
trait Matchable
class Any
object TypeTest

Attributes

Companion
trait
Source
TypeTest.scala
Supertypes
class Object
trait Matchable
class Any
Self type
TypeTest.type

Deprecated classlikes

Attributes

Deprecated
true
Source
ClassManifestDeprecatedApis.scala
Supertypes
trait OptManifest[T]
trait Serializable
class Object
trait Matchable
class Any
Known subtypes
trait ClassTag[T]
trait Manifest[T]
class AnyValManifest[T]
Self type

Types

type Typeable[T] = TypeTest[Any, T]

A shorhand for TypeTest[Any, T]. A Typeable[T] contains the logic needed to know at runtime if a value can be downcasted toT`.

A shorhand for TypeTest[Any, T]. A Typeable[T] contains the logic needed to know at runtime if a value can be downcasted toT`.

If a pattern match is performed on a term of type s: Any that is uncheckable with s.isInstanceOf[T] and the pattern are of the form:

  • t: T
  • t @ X() where the X.unapply has takes an argument of type T then a given instance of Typeable[T] (TypeTest[Any, T]) is summoned and used to perform the test.

Attributes

Source
Typeable.scala

Deprecated types

type ClassManifest[T] = ClassTag[T]

A ClassManifest[T] is an opaque descriptor for type T.

A ClassManifest[T] is an opaque descriptor for type T. It is used by the compiler to preserve information necessary for instantiating Arrays in those cases where the element type is unknown at compile time.

The type-relation operators make an effort to present a more accurate picture than can be realized with erased types, but they should not be relied upon to give correct answers. In particular they are likely to be wrong when variance is involved or when a subtype has a different number of type arguments than a supertype.

Attributes

Deprecated
true
Source
package.scala

Value members

Concrete methods

def classTag[T](implicit ctag: ClassTag[T]): ClassTag[T]

Attributes

Source
package.scala
def ensureAccessible[T <: AccessibleObject](m: T): T

Make a java reflection object accessible, if it is not already and it is possible to do so.

Make a java reflection object accessible, if it is not already and it is possible to do so. If a SecurityException is thrown in the attempt, it is caught and discarded.

Attributes

Source
package.scala

Deprecated fields

The object ClassManifest defines factory methods for manifests.

The object ClassManifest defines factory methods for manifests. It is intended for use by the compiler and should not be used in client code.

Attributes

Deprecated
true
Source
package.scala