Symbol

class Symbol extends Designator with ParamInfo with SrcPos with Showable

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

Value parameters:
coord

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

id

A unique identifier of the symbol (unique per ContextBase)

trait Showable
trait SrcPos
trait ParamInfo
class Object
trait Matchable
class Any
object NoSymbol.type

Type members

Value members

Concrete methods

final def asClass: ClassSymbol
final def asTerm(using Context): TermSymbol
final def asType(using Context): TypeSymbol

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

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

final def binaryFile(using Context): AbstractFile

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.

Extension method from Symbols

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

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

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

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

final def denot(using Context): SymDenotation

The current denotation of this symbol

The current denotation of this symbol

final def drop()(using Context): Unit

Remove symbol from scope of owning class

Remove symbol from scope of owning class

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.

final def entered(using Context): Symbol

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

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

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.

If this symbol satisfies predicate p this symbol, otherwise NoSymbol

If this symbol satisfies predicate p this symbol, otherwise NoSymbol

override def hashCode(): Int
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?

final def isPatternBound(using Context): Boolean

Is the symbol a pattern bound symbol?

Is the symbol a pattern bound symbol?

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.

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

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

Is symbol valid in current run?

Is symbol valid in current run?

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

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

final def name(using Context): ThisName

The current name of this symbol

The current name of this symbol

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

The original denotation of this symbol, without forcing anything

The original denotation of this symbol, without forcing anything

def paramInfo(using Context): Type

Does this symbol retain its definition tree? A good policy for this needs to balance costs and benefits, where costs are mainly memoty 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 memoty leaks, in particular across runs.

def showDcl(using Context): String
def showKind(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.

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.

See also:

enclosingSourceSymbols

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.

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.

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

override def toString: String
Definition Classes
Any
def toText(printer: Printer): Text

Inherited methods

def endPos(using ctx: Context): SourcePosition
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

Inherited from:
Showable
def focus(using ctx: Context): SourcePosition
Inherited from:
SrcPos
def line(using ctx: Context): Int
Inherited from:
SrcPos
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.

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

The string representation of this showable element.

The string representation of this showable element.

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).

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.

Inherited from:
Showable
Inherited from:
SrcPos

Concrete fields

val id: Int