Symbol

dotty.tools.dotc.core.Symbols.Symbol

A Symbol represents a Scala definition/declaration or a package.

Value parameters

id

A unique identifier of the symbol (unique per ContextBase)

myCoord

The coordinates of the symbol (a position or an index)

Attributes

Graph
Supertypes
trait Showable
trait SrcPos
trait ParamInfo
class Designator
class Object
trait Matchable
class Any
Show all
Known subtypes
class ClassSymbol
object NoSymbol

Members list

Type members

Types

type ThisName <: Name

Value members

Concrete methods

final def asClass: ClassSymbol
final def asTerm(using Context): TermSymbol
final def asType(using Context): TypeSymbol
def associatedFile(using Context): AbstractFile | Null

The source or class file from which this class or the class containing this symbol was generated, null if not applicable. Note that the returned classfile might be from the top-level class containing this symbol instead of the directly enclosing class.

The source or class file from which this class or the class containing this symbol was generated, null if not applicable. Note that the returned classfile might be from the top-level class containing this symbol instead of the directly enclosing class.

Attributes

final def binaryFile(using Context): AbstractFile | Null

The class file from which this class was generated, null if not applicable.

The class file from which this class was generated, null if not applicable.

Attributes

The compilation unit info (associated file, tasty versions, ...). Note that the returned CompilationUnitInfo might be from the top-level class containing this symbol instead of the directly enclosing class. Overridden in ClassSymbol

The compilation unit info (associated file, tasty versions, ...). Note that the returned CompilationUnitInfo might be from the top-level class containing this symbol instead of the directly enclosing class. Overridden in ClassSymbol

Attributes

def coord: Coord
def copy(using Context)(owner: Symbol, name: ThisName, flags: FlagSet, info: Type, privateWithin: Symbol, coord: Coord, compUnitInfo: CompilationUnitInfo | Null): Symbol

Copy a symbol, overriding selective fields. Note that coord and compilationUnitInfo will be set from the fields in owner, not the fields in sym.

Copy a symbol, overriding selective fields. Note that coord and compilationUnitInfo will be set from the fields in owner, not the fields in sym.

Attributes

def defTree: Tree

The tree defining the symbol at pickler time, EmptyTree if none was retained

The tree defining the symbol at pickler time, EmptyTree if none was retained

Attributes

def defTree_=(tree: Tree)(using Context): Unit

Set defining tree if this symbol retains its definition tree

Set defining tree if this symbol retains its definition tree

Attributes

final def denot(using Context): SymDenotation

The current denotation of this symbol

The current denotation of this symbol

Attributes

final def drop()(using Context): Unit

Remove symbol from scope of owning class

Remove symbol from scope of owning class

Attributes

def dropAfter(phase: DenotTransformer)(using Context): Unit

Remove symbol from scope of owning class after given phase. Create a fresh denotation for its owner class if the class does not already have one that starts being valid after phase.

Remove symbol from scope of owning class after given phase. Create a fresh denotation for its owner class if the class does not already have one that starts being valid after phase.

Attributes

final def entered(using Context): this.type

This symbol entered into owner's scope (owner must be a class).

This symbol entered into owner's scope (owner must be a class).

Attributes

def enteredAfter(phase: DenotTransformer)(using Context): this.type

Enter this symbol in its class owner after given phase. Create a fresh denotation for its owner class if the class does not already have one that starts being valid after phase.

Enter this symbol in its class owner after given phase. Create a fresh denotation for its owner class if the class does not already have one that starts being valid after phase.

Attributes

def filter(p: Symbol => Boolean): Symbol

If this symbol satisfies predicate p this symbol, otherwise NoSymbol

If this symbol satisfies predicate p this symbol, otherwise NoSymbol

Attributes

override def hashCode(): Int

Calculates a hash code value for the object.

Calculates a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Any
final def isClass: Boolean

Does this symbol come from a currently compiled source file?

Does this symbol come from a currently compiled source file?

Attributes

final def isDefinedInSource(using Context): Boolean

Is this symbol valid in the current run and has an associated file that is not a binary file. e.g. This will return true for symbols defined by the user in a prior run of the REPL, that are still valid.

Is this symbol valid in the current run and has an associated file that is not a binary file. e.g. This will return true for symbols defined by the user in a prior run of the REPL, that are still valid.

Attributes

final def isPatternBound(using Context): Boolean

Is the symbol a pattern bound symbol?

Is the symbol a pattern bound symbol?

Attributes

final def isPrivate(using Context): Boolean

Test whether symbol is private. This conservatively returns false if symbol does not yet have a denotation, or denotation is a class that is not yet read.

Test whether symbol is private. This conservatively returns false if symbol does not yet have a denotation, or denotation is a class that is not yet read.

Attributes

final def isStatic(using Context): Boolean

Special cased here, because it may be used on naked symbols in substituters

Special cased here, because it may be used on naked symbols in substituters

Attributes

final def isTerm(using Context): Boolean
final def isType(using Context): Boolean

Is this the info of a type parameter? Will return false for symbols that are not type parameters.

Is this the info of a type parameter? Will return false for symbols that are not type parameters.

Attributes

final def isValidInCurrentRun(using Context): Boolean

Is symbol valid in current run?

Is symbol valid in current run?

Attributes

The last known denotation of this symbol, without going through current

The last known denotation of this symbol, without going through current

Attributes

final def name(using Context): ThisName

The current name of this symbol

The current name of this symbol

Attributes

inline def orElse(inline that: Symbol)(using Context): Symbol

This symbol, if it exists, otherwise the result of evaluating that

This symbol, if it exists, otherwise the result of evaluating that

Attributes

The original denotation of this symbol, without forcing anything

The original denotation of this symbol, without forcing anything

Attributes

def paramInfo(using Context): Type

The info of the type parameter

The info of the type parameter

Attributes

def paramInfoAsSeenFrom(pre: Type)(using Context): Type

The info of the type parameter as seen from a prefix type. For type parameter symbols, this is the memberInfo as seen from prefix. For type lambda parameters, it's the same as paramInfos as asSeenFrom has already been applied to the whole type lambda.

The info of the type parameter as seen from a prefix type. For type parameter symbols, this is the memberInfo as seen from prefix. For type lambda parameters, it's the same as paramInfos as asSeenFrom has already been applied to the whole type lambda.

Attributes

The parameter bounds, or the completer if the type parameter is an as-yet uncompleted symbol.

The parameter bounds, or the completer if the type parameter is an as-yet uncompleted symbol.

Attributes

def paramName(using Context): ThisName

The name of the type parameter

The name of the type parameter

Attributes

def paramRef(using Context): TypeRef

A type that refers to the parameter

A type that refers to the parameter

Attributes

The variance of the type parameter

The variance of the type parameter

Attributes

Does this symbol retain its definition tree? A good policy for this needs to balance costs and benefits, where costs are mainly memory leaks, in particular across runs.

Does this symbol retain its definition tree? A good policy for this needs to balance costs and benefits, where costs are mainly memory leaks, in particular across runs.

Attributes

def showDcl(using Context): String
def showKind(using Context): String
def showLocated(using Context): String
def showName(using Context): String
final def signature(using Context): Signature

The symbol's signature if it is completed or a method, NotAMethod otherwise.

The symbol's signature if it is completed or a method, NotAMethod otherwise.

Attributes

final def source(using Context): SourceFile
final def sourcePos(using Context): SourcePosition
final def sourceSymbol(using Context): Symbol

A symbol related to sym that is defined in source code.

A symbol related to sym that is defined in source code.

Attributes

See also
final def span: Span

The position of this symbol, or NoSpan if the symbol was not loaded from source or from TASTY. This is always a zero-extent position.

The position of this symbol, or NoSpan if the symbol was not loaded from source or from TASTY. This is always a zero-extent position.

Attributes

final def srcPos: SrcPos

This positioned item, widened to SrcPos. Used to make clear we only need the position, typically for error reporting.

This positioned item, widened to SrcPos. Used to make clear we only need the position, typically for error reporting.

Attributes

final def symbol(implicit ev: DontUseSymbolOnSymbol): Nothing

A trap to avoid calling x.symbol on something that is already a symbol. This would be expanded to toDenot(x).symbol which is guaraneteed to be the same as x. With the given setup, all such calls will give implicit-not found errors

A trap to avoid calling x.symbol on something that is already a symbol. This would be expanded to toDenot(x).symbol which is guaraneteed to be the same as x. With the given setup, all such calls will give implicit-not found errors

Attributes

The info of the TASTy from which this symbol was loaded, None if not applicable.

The info of the TASTy from which this symbol was loaded, None if not applicable.

Attributes

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
def toText(printer: Printer): Text

The text representation of this showable element. This normally dispatches to a pattern matching method in Printers.

The text representation of this showable element. This normally dispatches to a pattern matching method in Printers.

Attributes

Inherited methods

def accessorNamed(name: TermName)(using Context): Symbol
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

The ConstantType of a val known to be isConstrExprFinalVal.

The ConstantType of a val known to be isConstrExprFinalVal.

Attributes

Inherited from:
SymUtils
Extension method from Symbols

The declared self type of this class, as seen from site, stripping all refinements for opaque types.

The declared self type of this class, as seen from site, stripping all refinements for opaque types.

Attributes

Inherited from:
SymUtils
def deriveTargetNameAnnotation(original: Symbol, nameFn: Name => Name)(using Context): Unit
Extension method from Symbols

If original has a target name annotation, add one to this symbol as well such that the new target name is original's target name transformed by nameFn.

If original has a target name annotation, add one to this symbol as well such that the new target name is original's target name transformed by nameFn.

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

All traits implemented by a class or trait except for those inherited through the superclass. Traits are given in the order they appear in the parents clause (which is the reverse of their order in baseClasses)

All traits implemented by a class or trait except for those inherited through the superclass. Traits are given in the order they appear in the parents clause (which is the reverse of their order in baseClasses)

Attributes

Inherited from:
SymUtils
Extension method from Symbols

The closest enclosing method or class of this symbol

The closest enclosing method or class of this symbol

Attributes

Inherited from:
SymUtils
final def enclosure(using Context): Symbol
Extension method from Symbols

The closest properly enclosing method or class of this symbol.

The closest properly enclosing method or class of this symbol.

Attributes

Inherited from:
SymUtils
def endPos(using ctx: Context): SourcePosition

Attributes

Inherited from:
SrcPos
def fallbackToText(printer: Printer): Text

A fallback text representation, if the pattern matching in Printers does not have a case for this showable element

A fallback text representation, if the pattern matching in Printers does not have a case for this showable element

Attributes

Inherited from:
Showable
def field(using Context): Symbol
Extension method from Symbols

Attributes

Inherited from:
SymUtils
def focus(using ctx: Context): SourcePosition

Attributes

Inherited from:
SrcPos
def getter(using Context): Symbol
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is this symbol a constant expression final val?

Is this symbol a constant expression final val?

This is the case if all of the following are true:

  • it is a final val,
  • its result type is a ConstantType, and
  • it does not need an explicit field because of Scala.js semantics (see JSSymUtils.sjsNeedsField).

Constant expression final vals do not need an explicit field to store their value. See the Memoize-Mixin-Constructors phase trio.

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is symbol assumed or declared as an infix symbol?

Is symbol assumed or declared as an infix symbol?

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
def isEnum(using Context): Boolean
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Does this symbol refer to anonymous classes synthesized by enum desugaring?

Does this symbol refer to anonymous classes synthesized by enum desugaring?

Attributes

Inherited from:
SymUtils
def isEnumCase(using Context): Boolean
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is symbol declared or inherits @experimental?

Is symbol declared or inherits @experimental?

Attributes

Inherited from:
SymUtils
def isField(using Context): Boolean
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
def isGenericSum(pre: Type)(using Context): Boolean
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is this the method that summons a structural given instance?

Is this the method that summons a structural given instance?

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is this symbol defined locally (i.e. at some level owned by a term) so that it cannot be seen from parent class cls?

Is this symbol defined locally (i.e. at some level owned by a term) so that it cannot be seen from parent class cls?

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
final def isLocal(using Context): Boolean
Extension method from Symbols

Is symbol directly or indirectly owned by a term symbol?

Is symbol directly or indirectly owned by a term symbol?

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is this symbol directly owner by a term symbol, i.e., is it local to a block?

Is this symbol directly owner by a term symbol, i.e., is it local to a block?

Attributes

Inherited from:
SymUtils
def isNoValue(using Context): Boolean
Extension method from Symbols

Attributes

Inherited from:
SymUtils
def isOldStyleImplicitConversion(directOnly: Boolean, forImplicitClassOnly: Boolean)(using Context): Boolean
Extension method from Symbols

Is this an old style implicit conversion?

Is this an old style implicit conversion?

Value parameters

directOnly

only consider explicitly written methods

forImplicitClassOnly

only consider methods generated from implicit classes

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is this a type or term parameter or a term parameter accessor?

Is this a type or term parameter or a term parameter accessor?

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
def isTypeCast(using Context): Boolean
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is symbol a type splice operation?

Is symbol a type splice operation?

Attributes

Inherited from:
SymUtils
def isTypeTest(using Context): Boolean
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
def isVolatile(using Context): Boolean
Extension method from Symbols

Attributes

Inherited from:
SymUtils
def line(using ctx: Context): Int

Attributes

Inherited from:
SrcPos
Extension method from Symbols

The return type as seen from the body of this definition. It is computed from the symbol's type by replacing param refs by param symbols.

The return type as seen from the body of this definition. It is computed from the symbol's type by replacing param refs by param symbols.

Attributes

Inherited from:
SymUtils
Extension method from Symbols

All traits implemented by a class, except for those inherited through the superclass. The empty list if self is a trait.

All traits implemented by a class, except for those inherited through the superclass. The empty list if self is a trait.

Attributes

Inherited from:
SymUtils
final def paramVarianceSign(using Context): Int

The variance of the type parameter, as a number -1, 0, +1. Bivariant is mapped to 1, i.e. it is treated like Covariant.

The variance of the type parameter, as a number -1, 0, +1. Bivariant is mapped to 1, i.e. it is treated like Covariant.

Attributes

Inherited from:
ParamInfo
def returnProto(using Context): Type
Extension method from Symbols

The expected type of a return to self at the place indicated by the context. This is the local return type instantiated by the symbols of any context function closures that enclose the site of the return

The expected type of a return to self at the place indicated by the context. This is the local return type instantiated by the symbols of any context function closures that enclose the site of the return

Attributes

Inherited from:
SymUtils
def setter(using Context): Symbol
Extension method from Symbols

Attributes

Inherited from:
SymUtils
def show(using Context): String

The string representation of this showable element.

The string representation of this showable element.

Attributes

Inherited from:
Showable
def showIndented(margin: Int)(using Context): String

The string representation with each line after the first one indented by the given given margin (in spaces).

The string representation with each line after the first one indented by the given given margin (in spaces).

Attributes

Inherited from:
Showable
def showSummary(depth: Int)(using Context): String

The summarized string representation of this showable element. Recursion depth is limited to some smallish value. Default is Config.summarizeDepth.

The summarized string representation of this showable element. Recursion depth is limited to some smallish value. Default is Config.summarizeDepth.

Attributes

Inherited from:
Showable
final def skipConstructor(using Context): Symbol
Extension method from Symbols

If this is a constructor, its owner: otherwise this.

If this is a constructor, its owner: otherwise this.

Attributes

Inherited from:
SymUtils
def startPos(using ctx: Context): SourcePosition

Attributes

Inherited from:
SrcPos
def subst(from: List[Symbol], to: List[Symbol]): Symbol
Extension method from Symbols

Apply symbol/symbol substitution to this symbol

Apply symbol/symbol substitution to this symbol

Attributes

Inherited from:
SymUtils
def traitSetter(using Context): Symbol
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Attributes

Inherited from:
SymUtils
Extension method from Symbols

Is this a case class for which a product mirror is generated? Excluded are value classes, abstract classes and case classes with more than one parameter section.

Is this a case class for which a product mirror is generated? Excluded are value classes, abstract classes and case classes with more than one parameter section.

Attributes

Inherited from:
SymUtils
def whyNotGenericSum(pre: Type)(using Context): String
Extension method from Symbols

Is this a sealed class or trait for which a sum mirror is generated? It must satisfy the following conditions:

Is this a sealed class or trait for which a sum mirror is generated? It must satisfy the following conditions:

  • it has at least one child class or object
  • none of its children are anonymous classes
  • all of its children are addressable through a path from the parent class and also the location of the generated mirror.
  • all of its children are generic products, singletons, or generic sums themselves.

Attributes

Inherited from:
SymUtils
def withAnnotationsCarrying(from: Symbol, meta: Symbol, orNoneOf: Set[Symbol])(using Context): self.type
Extension method from Symbols

Attributes

Inherited from:
SymUtils

Concrete fields

val id: Int