W3cubDocs

/Scala 2.13 Reflection

Trait scala.reflect.api.Symbols.SymbolApi

trait SymbolApi extends AnyRef

The API of symbols. The main source of information about symbols is the Symbols page.

Class Symbol defines isXXX test methods such as isPublic or isFinal, params and returnType methods for method symbols, baseClasses for class symbols and so on. Some of these methods don't make sense for certain subclasses of Symbol and return NoSymbol, Nil or other empty values.

Self Type
Universe.Symbol
Source
Symbols.scala
Linear Supertypes
AnyRef, Any
Known Subclasses
FreeTermSymbol, FreeTermSymbolApi, FreeTypeSymbol, FreeTypeSymbolApi, ClassSymbol, ClassSymbolApi, MethodSymbol, MethodSymbolApi, ModuleSymbol, ModuleSymbolApi, Symbol, TermSymbol, TermSymbolApi, TypeSymbol, TypeSymbolApi

Type Members

abstract type NameType >: Null <: Universe.Name

The type of the symbol name. Can be either TermName or TypeName depending on whether this is a TermSymbol or a TypeSymbol.

Type name namespaces do not intersect with term name namespaces. This fact is reflected in different types for names of TermSymbol and TypeSymbol.

Abstract Value Members

abstract def alternatives: List[Universe.Symbol]

abstract def annotations: List[Universe.Annotation]

abstract def companion: Universe.Symbol

For a class: its companion object if exists. For a module or a module class: companion class of the module if exists. For a package or a package class: NoSymbol. For all others: NoSymbol.

abstract def filter(cond: (Universe.Symbol) => Boolean): Universe.Symbol

Filters the underlying alternatives (or a single-element list composed of the symbol itself if the symbol is not overloaded). Returns an overloaded symbol is there are multiple matches. Returns a NoSymbol if there are no matches.

abstract def fullName: String

abstract def info: Universe.Type

The type signature of this symbol.

This method always returns signatures in the most generic way possible, even if the underlying symbol is obtained from an instantiation of a generic type. For example, signature of the method def map[B](f: (A) => B): List[B], which refers to the type parameter A of the declaring class List[A], will always feature A, regardless of whether map is loaded from the List[_] or from List[Int]. To get a signature with type parameters appropriately instantiated, one should use infoIn.

abstract def infoIn(site: Universe.Type): Universe.Type

abstract def isAbstract: Boolean

Is this symbol abstract (i.e. an abstract class, an abstract method, value or type member)?

abstract def isAbstractOverride: Boolean

abstract def isConstructor: Boolean

Does this method represent a constructor?

If owner is a class, then this is a vanilla JVM constructor. If owner is a trait, then this is a mixin constructor.

abstract def isFinal: Boolean

abstract def isImplementationArtifact: Boolean

abstract def isImplicit: Boolean

abstract def isJava: Boolean

abstract def isJavaAnnotation: Boolean

abstract def isJavaEnum: Boolean

abstract def isMacro: Boolean

abstract def isPackage: Boolean

abstract def isPackageClass: Boolean

abstract def isParameter: Boolean

abstract def isPrivate: Boolean

abstract def isPrivateThis: Boolean

abstract def isProtected: Boolean

abstract def isProtectedThis: Boolean

abstract def isPublic: Boolean

abstract def isSpecialized: Boolean

abstract def isStatic: Boolean

Is this symbol static (i.e. with no outer instance)? Q: When exactly is a sym marked as STATIC? A: If it's a member of a toplevel object, or of an object contained in a toplevel object, or any number of levels deep. http://groups.google.com/group/scala-internals/browse_thread/thread/d385bcd60b08faf6

abstract def isSynthetic: Boolean

Does this symbol represent a synthetic (i.e. a compiler-generated) entity? Examples of synthetic entities are accessors for vals and vars.

abstract def map(f: (Universe.Symbol) => Universe.Symbol): Universe.Symbol

abstract def name: Symbol.NameType

abstract def orElse(alt: => Universe.Symbol): Universe.Symbol

abstract def overrides: List[Universe.Symbol]

abstract def owner: Universe.Symbol

The owner of this symbol. This is the symbol that directly contains the current symbol's definition. The NoSymbol symbol does not have an owner, and calling this method on one causes an internal error. The owner of the Scala root class scala.reflect.api.Mirror.RootClass and the Scala root object scala.reflect.api.Mirror.RootPackage is NoSymbol. Every other symbol has a chain of owners that ends in scala.reflect.api.Mirror.RootClass.

abstract def pos: Universe.Position

abstract def privateWithin: Universe.Symbol

Set when symbol has a modifier of the form private[X] or protected[X], NoSymbol otherwise.

Access level encoding: there are three scala flags (PRIVATE, PROTECTED, and LOCAL) which combine with value privateWithin (the "foo" in private[foo]) to define from where an entity can be accessed. The meanings are as follows:

PRIVATE access restricted to class only. PROTECTED access restricted to class and subclasses only. LOCAL can only be set in conjunction with PRIVATE or PROTECTED. Further restricts access to the same object instance.

In addition, privateWithin can be used to set a visibility barrier. When set, everything contained in the named enclosing package or class has access. It is incompatible with PRIVATE or LOCAL, but is additive with PROTECTED (i.e. if either the flags or privateWithin allow access, then it is allowed.)

The java access levels translate as follows:

java private: isPrivate && (privateWithin == NoSymbol) java package: !isPrivate && !isProtected && (privateWithin == enclosingPackage) java protected: isProtected && (privateWithin == enclosingPackage) java public: !isPrivate && !isProtected && (privateWithin == NoSymbol)

abstract def suchThat(cond: (Universe.Symbol) => Boolean): Universe.Symbol

abstract def typeSignature: Universe.Type

See also

info

abstract def typeSignatureIn(site: Universe.Type): Universe.Type

See also

infoIn

abstract def allOverriddenSymbols: List[Universe.Symbol]

Annotations
@deprecated
Deprecated

(Since version 2.11.0) use overrides instead

See also

overrides

abstract def associatedFile: AbstractFile

Source file if this symbol is created during this compilation run, or a class file if this symbol is loaded from a *.class or *.jar.

The return type is scala.reflect.io.AbstractFile, which belongs to an experimental part of Scala reflection. It should not be used unless you know what you are doing. In subsequent releases, this API will be refined and exposed as a part of scala.reflect.api.

Annotations
@deprecated
Deprecated

(Since version 2.11.0) use pos.source.file instead

abstract def companionSymbol: Universe.Symbol

For a class: the module or case class factory with the same name in the same package. For a module: the class with the same name in the same package. For all others: NoSymbol.

This API may return unexpected results for module classes, packages and package classes. Use companion instead in order to get predictable results.

Annotations
@deprecated
Deprecated

(Since version 2.11.0) use companion instead, but beware of possible changes in behavior

Concrete Value Members

final def !=(arg0: Any): Boolean

Definition Classes
AnyRef → Any

final def ##(): Int

Definition Classes
AnyRef → Any

def +(other: String): String

Implicit
This member is added by an implicit conversion from Universe.SymbolApi toany2stringadd[Universe.SymbolApi] performed by method any2stringadd in scala.Predef.
Definition Classes
any2stringadd

def ->[B](y: B): (Universe.SymbolApi, B)

Implicit
This member is added by an implicit conversion from Universe.SymbolApi toArrowAssoc[Universe.SymbolApi] performed by method ArrowAssoc in scala.Predef.
Definition Classes
ArrowAssoc
Annotations
@inline()

final def ==(arg0: Any): Boolean

Definition Classes
AnyRef → Any

def asClass: Universe.ClassSymbol

This symbol cast to a ClassSymbol representing a class or trait.

Exceptions thrown

ScalaReflectionException if isClass is false.

final def asInstanceOf[T0]: T0

Definition Classes
Any

def asMethod: Universe.MethodSymbol

This symbol cast to a MethodSymbol.

Exceptions thrown

ScalaReflectionException if isMethod is false.

def asModule: Universe.ModuleSymbol

This symbol cast to a ModuleSymbol defined by an object definition.

Exceptions thrown

ScalaReflectionException if isModule is false.

def asTerm: Universe.TermSymbol

This symbol cast to a TermSymbol.

Exceptions thrown

ScalaReflectionException if isTerm is false.

def asType: Universe.TypeSymbol

This symbol cast to a TypeSymbol.

Exceptions thrown

ScalaReflectionException if isType is false.

def clone(): AnyRef

Attributes
protected[java.lang]
Definition Classes
AnyRef
Annotations
@throws(classOf[java.lang.CloneNotSupportedException]) @native()

def ensuring(cond: (Universe.SymbolApi) => Boolean, msg: => Any): Universe.SymbolApi

Implicit
This member is added by an implicit conversion from Universe.SymbolApi toEnsuring[Universe.SymbolApi] performed by method Ensuring in scala.Predef.
Definition Classes
Ensuring

def ensuring(cond: (Universe.SymbolApi) => Boolean): Universe.SymbolApi

Implicit
This member is added by an implicit conversion from Universe.SymbolApi toEnsuring[Universe.SymbolApi] performed by method Ensuring in scala.Predef.
Definition Classes
Ensuring

def ensuring(cond: Boolean, msg: => Any): Universe.SymbolApi

Implicit
This member is added by an implicit conversion from Universe.SymbolApi toEnsuring[Universe.SymbolApi] performed by method Ensuring in scala.Predef.
Definition Classes
Ensuring

def ensuring(cond: Boolean): Universe.SymbolApi

Implicit
This member is added by an implicit conversion from Universe.SymbolApi toEnsuring[Universe.SymbolApi] performed by method Ensuring in scala.Predef.
Definition Classes
Ensuring

final def eq(arg0: AnyRef): Boolean

Definition Classes
AnyRef

def equals(arg0: AnyRef): Boolean

Definition Classes
AnyRef → Any

def finalize(): Unit

Attributes
protected[java.lang]
Definition Classes
AnyRef
Annotations
@throws(classOf[java.lang.Throwable])

def formatted(fmtstr: String): String

Implicit
This member is added by an implicit conversion from Universe.SymbolApi toStringFormat[Universe.SymbolApi] performed by method StringFormat in scala.Predef.
Definition Classes
StringFormat
Annotations
@inline()

final def getClass(): Class[_ <: AnyRef]

Definition Classes
AnyRef → Any
Annotations
@native()

def hashCode(): Int

Definition Classes
AnyRef → Any
Annotations
@native()

def isClass: Boolean

final def isInstanceOf[T0]: Boolean

Definition Classes
Any

def isMethod: Boolean

def isModule: Boolean

Does this symbol represent the definition of a module (i.e. it results from an object definition?). If yes, isTerm is also guaranteed to be true.

def isModuleClass: Boolean

def isOverloadedMethod: Boolean

Used to provide a better error message for asMethod.

Attributes
protected

def isTerm: Boolean

Does this symbol represent the definition of a term? Note that every symbol is either a term or a type. So for every symbol sym (except for NoSymbol), either sym.isTerm is true or sym.isType is true.

def isType: Boolean

Does this symbol represent the definition of a type? Note that every symbol is either a term or a type. So for every symbol sym (except for NoSymbol), either sym.isTerm is true or sym.isType is true.

final def ne(arg0: AnyRef): Boolean

Definition Classes
AnyRef

final def notify(): Unit

Definition Classes
AnyRef
Annotations
@native()

final def notifyAll(): Unit

Definition Classes
AnyRef
Annotations
@native()

final def synchronized[T0](arg0: => T0): T0

Definition Classes
AnyRef

def toString(): String

Definition Classes
AnyRef → Any

final def wait(): Unit

Definition Classes
AnyRef
Annotations
@throws(classOf[java.lang.InterruptedException])

final def wait(arg0: Long, arg1: Int): Unit

Definition Classes
AnyRef
Annotations
@throws(classOf[java.lang.InterruptedException])

final def wait(arg0: Long): Unit

Definition Classes
AnyRef
Annotations
@throws(classOf[java.lang.InterruptedException]) @native()

© 2002-2019 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://www.scala-lang.org/api/2.13.0/scala-reflect/scala/reflect/api/Symbols$SymbolApi.html