TypedTreeInfo

trait TypedTreeInfo extends TreeInfo[Type]
trait TreeInfo[Type]
class Object
trait Matchable
class Any
object tpd

Type members

Classlikes

Extractor for not-null assertions. A not-null assertion for reference x has the form x.$asInstanceOf$[x.type & T].

Extractor for not-null assertions. A not-null assertion for reference x has the form x.$asInstanceOf$[x.type & T].

object Quoted

Extractors for quotes

Extractors for quotes

object Spliced

Extractors for splices

Extractors for splices

object SplicedType

Extractors for type splices

Extractors for type splices

object closure

An extractor for closures, either contained in a block or standalone.

An extractor for closures, either contained in a block or standalone.

object closureDef

An extractor for def of a closure contained the block of the closure.

An extractor for def of a closure contained the block of the closure.

Inherited classlikes

class MatchingArgs(params: List[Symbol], args: List[Tree])(using `x$3`: Context)
Inherited from
TreeInfo

Value members

Concrete methods

def allArgss(tree: `<none>`): List[List[`<none>`]]

The type and term arguments of a possibly curried call, in the order they are given

The type and term arguments of a possibly curried call, in the order they are given

def assertAllPositioned(tree: `<none>`)(using Context): Unit
def closureBody(tree: `<none>`)(using Context): `<none>`

If tree is a closure, its body, otherwise tree itself

If tree is a closure, its body, otherwise tree itself

def constToLiteral(tree: `<none>`)(using Context): `<none>`

(1) If tree is a constant expression, its value as a Literal, or tree itself otherwise.

(1) If tree is a constant expression, its value as a Literal, or tree itself otherwise.

Note: Demanding idempotency instead of purity in literalize is strictly speaking too loose. Example

object O { final val x = 42; println("43") } O.x

Strictly speaking we can't replace O.x with 42. But this would make most expressions non-constant. Maybe we can change the spec to accept this kind of eliding behavior. Or else enforce true purity in the compiler. The choice will be affected by what we will do with inline and with Singleton type bounds (see SIP 23). Presumably

object O1 { val x: Singleton = 42; println("43") } object O2 { inline val x = 42; println("43") }

should behave differently.

O1.x should have the same effect as { println("43"); 42 }

whereas

O2.x = 42

Revisit this issue once we have standardized on inline. Then we can demand purity of the prefix unless the selection goes to a inline val.

Note: This method should be applied to all term tree nodes that are not literals, that can be idempotent, and that can have constant types. So far, only nodes of the following classes qualify:

  Ident
  Select
  TypeApply

(2) A primitive unary operator expression pre.op where op is one of +, -, ~, ! that has a constant type ConstantType(v) but that is not a constant expression (i.e. pre has side-effects) is translated to

{ pre; v }

(3) An expression pre.getClass[..]() that has a constant type ConstantType(v) but where pre has side-effects is translated to:

{ pre; v }

This avoids the situation where we have a Select node that does not have a symbol.

def decomposeTemplateBody(body: List[`<none>`])(using Context): (List[`<none>`], List[`<none>`])

Decompose a template body into parameters and other statements

Decompose a template body into parameters and other statements

def defPath(sym: Symbol, root: `<none>`)(using Context): List[`<none>`]

Going from child to parent, the path of tree nodes that starts with a definition of symbol sym and ends with root, or Nil if no such path exists. Pre: sym must have a position.

Going from child to parent, the path of tree nodes that starts with a definition of symbol sym and ends with root, or Nil if no such path exists. Pre: sym must have a position.

def definedSym(tree: `<none>`)(using Context): Symbol

If tree is a DefTree, the symbol defined by it, otherwise NoSymbol

If tree is a DefTree, the symbol defined by it, otherwise NoSymbol

def definingStats(sym: Symbol)(using Context): List[`<none>`]

The statement sequence that contains a definition of sym, or Nil if none was found. For a tree to be found, The symbol must have a position and its definition tree must be reachable from come tree stored in an enclosing context.

The statement sequence that contains a definition of sym, or Nil if none was found. For a tree to be found, The symbol must have a position and its definition tree must be reachable from come tree stored in an enclosing context.

def exprPurity(tree: `<none>`)(using Context): PurityLevel

The purity level of this expression. See docs for PurityLevel for what that means

The purity level of this expression. See docs for PurityLevel for what that means

Note that purity and idempotency are treated differently. References to modules and lazy vals are impure (side-effecting) both because side-effecting code may be executed and because the first reference takes a different code path than all to follow; but they are idempotent because running the expression a second time gives the cached result.

def funPart(tree: `<none>`): `<none>`

The function part of a possibly curried call. Unlike methPart this one does not decompose blocks

The function part of a possibly curried call. Unlike methPart this one does not decompose blocks

def isCatchCase(cdef: `<none>`)(using Context): Boolean

Is this pattern node a catch-all or type-test pattern?

Is this pattern node a catch-all or type-test pattern?

def isExtMethodApply(tree: `<none>`)(using Context): Boolean
def isIdempotentExpr(tree: `<none>`)(using Context): Boolean
def isIdempotentPath(tree: `<none>`)(using Context): Boolean
def isIdempotentRef(tree: `<none>`)(using Context): Boolean
def isPureApply(tree: `<none>`, fn: `<none>`)(using Context): Boolean

Is the application tree with function part fn known to be pure? Function value and arguments can still be impure.

Is the application tree with function part fn known to be pure? Function value and arguments can still be impure.

def isPureBinding(tree: `<none>`)(using Context): Boolean
def isPureExpr(tree: `<none>`)(using Context): Boolean
def isPurePath(tree: `<none>`)(using Context): Boolean
def isPureRef(tree: `<none>`)(using Context): Boolean
def isSelf(tree: `<none>`, enclClass: Symbol)(using Context): Boolean

Is tree a this node which belongs to enclClass?

Is tree a this node which belongs to enclClass?

def isStructuralTermSelectOrApply(tree: `<none>`)(using Context): Boolean

Is this a (potentially applied) selection of a member of a structural type that is not a member of an underlying class or trait?

Is this a (potentially applied) selection of a member of a structural type that is not a member of an underlying class or trait?

def isVariableOrGetter(tree: `<none>`)(using Context): Boolean

Is tree a reference to a mutable variable, or to a potential getter that has a setter in the same class?

Is tree a reference to a mutable variable, or to a potential getter that has a setter in the same class?

def localSyms(stats: List[`<none>`])(using Context): List[Symbol]

The symbols defined locally in a statement list

The symbols defined locally in a statement list

Is symbol potentially a getter of a mutable variable?

Is symbol potentially a getter of a mutable variable?

def patVars(tree: `<none>`)(using Context): List[Symbol]

The variables defined by a pattern, in reverse order of their appearance.

The variables defined by a pattern, in reverse order of their appearance.

def qualifier(tree: `<none>`)(using Context): `<none>`

The qualifier part of a Select or Ident. For an Ident, this is the This of the current class.

The qualifier part of a Select or Ident. For an Ident, this is the This of the current class.

def refPurity(tree: `<none>`)(using Context): PurityLevel

The purity level of this reference.

The purity level of this reference.

Returns

PurePath if reference is (nonlazy and stable) or to a parameterized function or its type is a constant type IdempotentPath if reference is lazy and stable Impure otherwise

def sliceTopLevel(tree: `<none>`, cls: ClassSymbol)(using Context): List[`<none>`]

The tree containing only the top-level classes and objects matching either cls or its companion object

The tree containing only the top-level classes and objects matching either cls or its companion object

final def splitAtSuper(constrStats: List[`<none>`])(implicit ctx: Context): (List[`<none>`], List[`<none>`])

Return a pair consisting of (supercall, rest)

Return a pair consisting of (supercall, rest)

  • supercall: the superclass call, excluding trait constr calls

The supercall is always the first statement (if it exists)

def statPurity(tree: `<none>`)(using Context): PurityLevel

The purity level of this statement.

The purity level of this statement.

Returns

Pure if statement has no side effects Idempotent if running the statement a second time has no side effects Impure otherwise

def stripCast(tree: `<none>`)(using Context): `<none>`

Strips layers of .asInstanceOf[T] / _.$asInstanceOf[T]() from an expression

Strips layers of .asInstanceOf[T] / _.$asInstanceOf[T]() from an expression

def termArgss(tree: `<none>`): List[List[`<none>`]]

The term arguments of a possibly curried call

The term arguments of a possibly curried call

def topLevelClasses(tree: `<none>`)(using Context): List[ClassSymbol]

The top level classes in this tree, including only those module classes that are not a linked class of some other class in the result.

The top level classes in this tree, including only those module classes that are not a linked class of some other class in the result.

def tupleArgs(tree: `<none>`)(using Context): List[`<none>`]

If tree is an instance of TupleN[...](e1, ..., eN), the arguments e1, ..., eN otherwise the empty list.

If tree is an instance of TupleN[...](e1, ..., eN), the arguments e1, ..., eN otherwise the empty list.

def typeArgss(tree: `<none>`): List[List[`<none>`]]

The type arguments of a possibly curried call

The type arguments of a possibly curried call

Inherited methods

def allParamSyms(ddef: `<none>`)(using Context): List[Symbol]

All type and value parameter symbols of this DefDef

All type and value parameter symbols of this DefDef

Inherited from
TreeInfo
def arguments(tree: `<none>`): List[`<none>`]

The (last) list of arguments of an application

The (last) list of arguments of an application

Inherited from
TreeInfo
def catchesAllOf(cdef: `<none>`, threshold: Type)(using Context): Boolean

Does this CaseDef catch everything of a certain Type?

Does this CaseDef catch everything of a certain Type?

Inherited from
TreeInfo
def catchesThrowable(cdef: `<none>`)(using Context): Boolean

Does this CaseDef catch Throwable?

Does this CaseDef catch Throwable?

Inherited from
TreeInfo
def firstConstructor(stats: List[`<none>`]): `<none>`

The first constructor definition in stats

The first constructor definition in stats

Inherited from
TreeInfo
def forallResults(tree: `<none>`, p: `<none>` => Boolean): Boolean

Checks whether predicate p is true for all result parts of this expression, where we zoom into Ifs, Matches, and Blocks.

Checks whether predicate p is true for all result parts of this expression, where we zoom into Ifs, Matches, and Blocks.

Inherited from
TreeInfo
def hasNamedArg(args: List[Any]): Boolean

Does this list contain a named argument tree?

Does this list contain a named argument tree?

Inherited from
TreeInfo
def isBackquoted(tree: `<none>`): Boolean

Is tree a backquoted identifier or definition

Is tree a backquoted identifier or definition

Inherited from
TreeInfo
def isDeclarationOrTypeDef(tree: `<none>`): Boolean
Inherited from
TreeInfo
def isDefaultCase(cdef: `<none>`): Boolean

Is this pattern node a catch-all (wildcard or variable) pattern?

Is this pattern node a catch-all (wildcard or variable) pattern?

Inherited from
TreeInfo
def isGuardedCase(cdef: `<none>`): Boolean

Is this case guarded?

Is this case guarded?

Inherited from
TreeInfo
def isOpAssign(tree: `<none>`): Boolean
Inherited from
TreeInfo
def isPath(tree: `<none>`): Boolean

Is tree a path?

Is tree a path?

Inherited from
TreeInfo
def isRepeatedParamType(tpt: `<none>`)(using Context): Boolean

Is tpt a vararg type of the form T* or => T*?

Is tpt a vararg type of the form T* or => T*?

Inherited from
TreeInfo
def isSelfConstrCall(tree: `<none>`): Boolean

Is tree a self constructor call this(...)? I.e. a call to a constructor of the same object?

Is tree a self constructor call this(...)? I.e. a call to a constructor of the same object?

Inherited from
TreeInfo
def isSelfOrSuperConstrCall(tree: `<none>`): Boolean
Inherited from
TreeInfo
def isSuperConstrCall(tree: `<none>`): Boolean

Is tree a super constructor call?

Is tree a super constructor call?

Inherited from
TreeInfo
def isSuperSelection(tree: `<none>`): Boolean
Inherited from
TreeInfo
def isSyntheticDefaultCase(cdef: `<none>`): Boolean

Is this pattern node a synthetic catch-all case, added during PartialFuction synthesis before we know whether the user provided cases are exhaustive.

Is this pattern node a synthetic catch-all case, added during PartialFuction synthesis before we know whether the user provided cases are exhaustive.

Inherited from
TreeInfo
def isTypeParamClause(params: `<none>`)(using Context): Boolean
Inherited from
TreeInfo
def isUsingClause(params: `<none>`)(using Context): Boolean

Is this parameter list a using clause?

Is this parameter list a using clause?

Inherited from
TreeInfo
def isUsingOrTypeParamClause(params: `<none>`)(using Context): Boolean
Inherited from
TreeInfo
def isVarPattern(pat: `<none>`): Boolean

Is tree a variable pattern?

Is tree a variable pattern?

Inherited from
TreeInfo
def isWildcardArg(tree: `<none>`): Boolean

Is the argument a wildcard argument of the form _ or x @ _?

Is the argument a wildcard argument of the form _ or x @ _?

Inherited from
TreeInfo
def isWildcardStarArg(tree: `<none>`)(using Context): Boolean

Is this argument node of the form *, or is it a reference to such an argument ? The latter case can happen when an argument is lifted.

Is this argument node of the form *, or is it a reference to such an argument ? The latter case can happen when an argument is lifted.

Inherited from
TreeInfo
def isWildcardStarArgList(trees: List[`<none>`])(using Context): Boolean

Does this argument list end with an argument of the form : _* ?

Does this argument list end with an argument of the form : _* ?

Inherited from
TreeInfo
def languageImport(path: `<none>`): Option[TermName]

If path looks like a language import, Some(name) where name is experimental if that sub-module is imported, and the empty term name otherwise.

If path looks like a language import, Some(name) where name is experimental if that sub-module is imported, and the empty term name otherwise.

Inherited from
TreeInfo
def methPart(tree: `<none>`): `<none>`

The method part of an application node, possibly enclosed in a block with only valdefs as statements. the reason for also considering blocks is that named arguments can transform a call into a block, e.g. (b = foo, a = bar) is transformed to { val x$1 = foo val x$2 = bar (x$2, x$1) }

The method part of an application node, possibly enclosed in a block with only valdefs as statements. the reason for also considering blocks is that named arguments can transform a call into a block, e.g. (b = foo, a = bar) is transformed to { val x$1 = foo val x$2 = bar (x$2, x$1) }

Inherited from
TreeInfo
def numArgs(tree: `<none>`): Int

The number of arguments in an application

The number of arguments in an application

Inherited from
TreeInfo
def parentsKind(parents: List[`<none>`])(using Context): FlagSet

The largest subset of {NoInits, PureInterface} that a trait or class with these parents can have as flags.

The largest subset of {NoInits, PureInterface} that a trait or class with these parents can have as flags.

Inherited from
TreeInfo
def stripAnnotated(tree: `<none>`): `<none>`
Inherited from
TreeInfo
def stripApply(tree: `<none>`): `<none>`

If this is an application, its function part, stripping all Apply nodes (but leaving TypeApply nodes in). Otherwise the tree itself.

If this is an application, its function part, stripping all Apply nodes (but leaving TypeApply nodes in). Otherwise the tree itself.

Inherited from
TreeInfo
def stripBlock(tree: `<none>`): `<none>`

If this is a block, its expression part

If this is a block, its expression part

Inherited from
TreeInfo
def stripInlined(tree: `<none>`): `<none>`
Inherited from
TreeInfo
def unbind(x: `<none>`): `<none>`

The underlying pattern ignoring any bindings

The underlying pattern ignoring any bindings

Inherited from
TreeInfo
def unsplice(tree: Tree[Type]): Tree[Type]
Inherited from
TreeInfo

Inherited fields

val isNamedArg: Any => Boolean
Inherited from
TreeInfo

Extensions

Extensions

extension (t1: Tree)
def ===(t2: Tree)(using Context): Boolean

Structural tree comparison (since == on trees is reference equality). For the moment, only Ident, Select, Literal, Apply and TypeApply are supported

Structural tree comparison (since == on trees is reference equality). For the moment, only Ident, Select, Literal, Apply and TypeApply are supported

def hash(using Context): Int

Structural tree comparison (since == on trees is reference equality). For the moment, only Ident, Select, Literal, Apply and TypeApply are supported

Structural tree comparison (since == on trees is reference equality). For the moment, only Ident, Select, Literal, Apply and TypeApply are supported