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 DeepFolder[X](f: (X, Tree) => X)

Fold f over all tree nodes, in depth-first, prefix order

Fold f over all tree nodes, in depth-first, prefix order

Inherited from
Instance
class MatchingArgs(params: List[Symbol], args: List[Tree])(using x$3: Context)
Inherited from
TreeInfo
class ShallowFolder[X](f: (X, Tree) => X)

Fold f over all tree nodes, in depth-first, prefix order, but don't visit subtrees where f returns a different result for the root, i.e. f(x, root) ne x.

Fold f over all tree nodes, in depth-first, prefix order, but don't visit subtrees where f returns a different result for the root, i.e. f(x, root) ne x.

Inherited from
Instance
abstract class TreeAccumulator[X]
Inherited from
Instance
abstract class TreeCopier

A class for copying trees. The copy methods avoid creating a new tree If all arguments stay the same.

A class for copying trees. The copy methods avoid creating a new tree If all arguments stay the same.

Note: Some of the copy methods take a context. These are exactly those methods that are overridden in TypedTreeCopier so that they selectively retype themselves. Retyping needs a context.

Inherited from
Instance
abstract class TreeMap(val cpy: TreeCopier)
Inherited from
Instance
abstract class TreeTraverser
Inherited from
Instance
object TypeDefs
Inherited from
Instance
object ValDefs
Inherited from
Instance

Inherited types

Inherited from
Instance
Inherited from
Instance
type Apply = Apply[T]
Inherited from
Instance
type Assign = Assign[T]
Inherited from
Instance
type Bind = Bind[T]
Inherited from
Instance
type Block = Block[T]
Inherited from
Instance
Inherited from
Instance
type CaseDef = CaseDef[T]
Inherited from
Instance
type Closure = Closure[T]
Inherited from
Instance
type DefDef = DefDef[T]
Inherited from
Instance
type DefTree = DefTree[T]
Inherited from
Instance
Inherited from
Instance
type Export = Export[T]
Inherited from
Instance
Inherited from
Instance
type Ident = Ident[T]
Inherited from
Instance
type If = If[T]
Inherited from
Instance
type Import = Import[T]
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
type Inlined = Inlined[T]
Inherited from
Instance
Inherited from
Instance
type Labeled = Labeled[T]
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
type Literal = Literal[T]
Inherited from
Instance
type Match = Match[T]
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
type New = New[T]
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
type RefTree = RefTree[T]
Inherited from
Instance
type Return = Return[T]
Inherited from
Instance
type Select = Select[T]
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
type Super = Super[T]
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
type Thicket = Thicket[T]
Inherited from
Instance
type This = This[T]
Inherited from
Instance
type Tree = Tree[T]
Inherited from
Instance
type Try = Try[T]
Inherited from
Instance
type TypTree = TypTree[T]
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
type TypeDef = TypeDef[T]
Inherited from
Instance
Inherited from
Instance
type Typed = Typed[T]
Inherited from
Instance
type UnApply = UnApply[T]
Inherited from
Instance
type ValDef = ValDef[T]
Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
type WhileDo = WhileDo[T]
Inherited from
Instance

Value members

Inherited constructors

def this()
Inherited from
Instance

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

protected def FunProto(args: List[Tree], resType: Type)(using Context): FunProto

Delegate to FunProto or FunProtoTyped depending on whether the prefix is untpd or tpd.

Delegate to FunProto or FunProtoTyped depending on whether the prefix is untpd or tpd.

Inherited from
Instance
def Thicket(xs: List[Tree])(implicit src: SourceFile): Thicket[T]
Inherited from
Instance
def Thicket(x1: Tree, x2: Tree, x3: Tree)(implicit src: SourceFile): Thicket
Inherited from
Instance
def Thicket(x1: Tree, x2: Tree)(implicit src: SourceFile): Thicket
Inherited from
Instance
Inherited from
Instance
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 applyOverloaded(receiver: Tree, method: TermName, args: List[Tree], targs: List[Type], expectedType: Type)(using parentCtx: Context): Tree

Construct the application $receiver.$method[$targs]($args) using overloading resolution to find a matching overload of $method if necessary. This is useful when overloading resolution needs to be performed in a phase after typer. Note that this will not perform any kind of implicit search.

Construct the application $receiver.$method[$targs]($args) using overloading resolution to find a matching overload of $method if necessary. This is useful when overloading resolution needs to be performed in a phase after typer. Note that this will not perform any kind of implicit search.

Value Params
expectedType

An expected type of the application used to guide overloading resolution

Inherited from
Instance
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
Inherited from
Instance
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 flatTree(xs: List[Tree])(implicit src: SourceFile): Tree
Inherited from
Instance
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
protected def inlineContext(call: Tree)(using Context): Context

For untyped trees, this is just the identity. For typed trees, a context derived form ctx that records call as the innermost enclosing call for which the inlined version is currently processed.

For untyped trees, this is just the identity. For typed trees, a context derived form ctx that records call as the innermost enclosing call for which the inlined version is currently processed.

Inherited from
Instance
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
Inherited from
Instance
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 joinParams(tparams: List[TypeDef], paramss: List[ParamClause]): List[ParamClause]

If tparams is non-empty, add it to the left paramss, merging it with a leading type parameter list of paramss, if one exists.

If tparams is non-empty, add it to the left paramss, merging it with a leading type parameter list of paramss, if one exists.

Inherited from
Instance
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 localCtx(tree: Tree)(using Context): Context

The context to use when mapping or accumulating over a tree

The context to use when mapping or accumulating over a tree

Inherited from
Instance
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 rename(tree: NameTree, newName: Name)(using Context): ThisTree[T]
Inherited from
Instance
def resolveConstructor(atp: Type, args: List[Tree])(using Context): Tree
Inherited from
Instance
protected def skipTransform(tree: Tree)(using Context): Boolean

Hook to indicate that a transform of some subtree should be skipped

Hook to indicate that a transform of some subtree should be skipped

Inherited from
Instance
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
Inherited from
Instance
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

Inherited from
Instance
Inherited from
Instance
Inherited from
Instance
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