Extension methods ofSymbol
Returns all symbols overridden by this symbol.
Annotations attached to this symbol
Returns a nested quote with this symbol as splice owner (Symbol.spliceOwner).
Returns a nested quote with this symbol as splice owner (Symbol.spliceOwner).
Changes the owner under which the definition in a quote are created.
Usages:
def rhsExpr(using q: Quotes): Expr[Unit] = import q.reflect.* '{ val y = ???; (y, y) }def aValDef(using q: Quotes)(owner: q.reflect.Symbol) = import q.reflect.* val sym = Symbol.newVal(owner, "x", TypeRepr.of[Unit], Flags.EmptyFlags, Symbol.noSymbol) val rhs = rhsExpr(using sym.asQuotes).asTerm ValDef(sym, Some(rhs))def inQuotes(using q: Quotes) = { import q.reflect.*new TreeMap: override def transformTerm(tree: Term)(owner: Symbol): Term = tree match case tree: Ident => given Quotes = owner.asQuotes // Definitions contained in the quote will be owned by `owner`. // No need to use `changeOwner` in this case. '{ val x = ???; x }.asTerm}Fields of a case class type -- only the ones declared in primary constructor
Fields of a case class type -- only the ones declared in primary constructor
Case class or case object children of a sealed trait or cases of anenum.
Case class or case object children of a sealed trait or cases of anenum.
The symbol of the companion class
The symbol of the companion module
All members directly declared in the class
Field with the given name directly declared in the class
Fields directly declared in the class
Get non-private named methods defined directly inside the class
Get all non-private methods defined directly inside the class, excluding constructors
Get all non-private methods defined directly inside the class, excluding constructors
Get non-private named type defined directly inside the class
Get all non-private types defined directly inside the class
The documentation for this symbol, if any
Does this symbol represent a definition?
Get named non-private fields declared or inherited
Get all non-private fields declared or inherited
Flags of this symbol
The full name of this symbol up to the root package
Get the annotation defined withannotSym attached to this symbol
Is the annotation defined withannotSym attached to this symbol?
Type of the definition
Is this symbol an abstract type or a type parameter?
Is this symbol an alias type?
Is this symbol an anonymous class?
Is this symbol an anonymous function?
Is this the definition of a Bind pattern?
Is this the constructor of a class?
Is this the definition of a ClassDef tree?
Is this the definition of a DefDef tree?
Does this symbol come from a currently compiled source file?
Dummy val symbol that owns all statements within the initialization of the class. This may also contain local definitions such as classes defined in alocally block in the class.
Dummy val symbol that owns all statements within the initialization of the class. This may also contain local definitions such as classes defined in alocally block in the class.
Does this symbol represent a no definition?
Is this the definition of a PackageDef tree?
Is this symbol a class representing a refinement?
Is this the super accessor?
Is this the definition of a term?
Is this the definition of a type?
Is this the definition of a TypeDef tree
Is this the symbol of a type parameter
Is this the definition of a ValDef tree?
Owner of this symbol. The owner is the symbol in which this symbol is defined. ReturnsNoSymbol if this symbol does not have an owner.
Owner of this symbol. The owner is the symbol in which this symbol is defined. ReturnsNoSymbol if this symbol does not have an owner.
Get named non-private fields declared or inherited
Get named non-private fields declared or inherited
[Since version 3.1.0]Use fieldMemberGet all non-private fields declared or inherited
Get all non-private fields declared or inherited
[Since version 3.1.0]Use fieldMembersGet named non-private methods declared or inherited
Get named non-private methods declared or inherited
[Since version 3.1.0]Use methodMemberGet all non-private methods declared or inherited
Get all non-private methods declared or inherited
[Since version 3.1.0]Use methodMembersType member with the given name directly declared in the class
Type member with the given name directly declared in the class
[Since version 3.1.0]Use declaredType or typeMemberType member directly declared in the class
Type member directly declared in the class
[Since version 3.1.0]Use declaredTypes or typeMembersGet named non-private methods declared or inherited
Get all non-private methods declared or inherited
The class symbol of the companion module class
The name of this symbol
The symbol overriding this symbol in given subclassofclazz.
The symbol overriding this symbol in given subclassofclazz.
is a subclass of this symbol's owner
Owner of this symbol. The owner is the symbol in which this symbol is defined. Throws if this symbol does not have an owner.
Owner of this symbol. The owner is the symbol in which this symbol is defined. Throws if this symbol does not have an owner.
The symbols of each type parameter list and value parameter list of this method, or Nil if this isn't a method.
The symbols of each type parameter list and value parameter list of this method, or Nil if this isn't a method.
Variance flags for of this type parameter.
Variance flags for of this type parameter.
Variance flags can be one ofFlags.{Covariant, Contravariant, EmptyFlags}. If this is not the symbol of a type parameter the result isFlags.EmptyFlags.
The position of this symbol
The primary constructor of a class or trait,noSymbol if not applicable.
The primary constructor of a class or trait,noSymbol if not applicable.
This symbol is private within the resulting type
This symbol is protected within the resulting type
Signature of this definition
Term reference to the symbol usable in the scope of its owner.
Tree of this definition
Tree of this definition
If this symbolisClassDef it will returnaClassDef, if this symbolisTypeDefit will returnaTypeDef, if this symbolisValDef it will returnaValDef, if this symbolisDefDefit will returnaDefDef if this symbolisBind it will returnaBind`, else will throw
Warning: avoid using this method in macros.
Caveat: The tree is not guaranteed to exist unless the compiler option-Yretain-trees is enabled.
Anti-pattern: The following code is an anti-pattern:
symbol.tree.tpeIt should be replaced by one of the following:
tp.memberType(symbol)symbol.typeRefsymbol.termRefType member with the given name declared or inherited in the class
Type member directly declared or inherited in the class
Type reference to the symbol usable in the scope of its owner.
Type reference to the symbol usable in the scope of its owner.
To get a reference to a symbol from a specific prefixtp, usetp.select(symbol) instead.
TypeReprMethods.select