tpd

dotty.tools.dotc.ast.tpd
object tpd extends Instance[Type], TypedTreeInfo

Some creators for typed trees

Attributes

Graph
Supertypes
trait TreeInfo[Type]
class Instance[Type]
class Object
trait Matchable
class Any
Show all
Self type
tpd.type

Members list

Type members

Classlikes

final class Counter

Attributes

Supertypes
class Object
trait Matchable
class Any
object MaybePoly

An extractor that pulls out type arguments

An extractor that pulls out type arguments

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
MaybePoly.type

Attributes

Supertypes
class TreeCopier
class Object
trait Matchable
class Any

A treemap that generates the same contexts as the original typer for statements. This means:

A treemap that generates the same contexts as the original typer for statements. This means:

  • statements that are not definitions get the exprOwner as owner
  • imports are reflected in the contexts of subsequent statements

Attributes

Supertypes
class TreeMap
class Object
trait Matchable
class Any
Known subtypes
final implicit class TreeOps[ThisTree <: Tree](tree: ThisTree) extends AnyVal

Attributes

Supertypes
class AnyVal
trait Matchable
class Any
trait TreeProvider

A trait for loaders that compute trees. Currently implemented just by DottyUnpickler.

A trait for loaders that compute trees. Currently implemented just by DottyUnpickler.

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes

A tree traverser that generates the the same import contexts as original typer for statements. TODO: Should we align TreeMapWithPreciseStatContexts and also keep track of exprOwners?

A tree traverser that generates the the same import contexts as original typer for statements. TODO: Should we align TreeMapWithPreciseStatContexts and also keep track of exprOwners?

Attributes

Supertypes
class Object
trait Matchable
class Any
object TypeArgs

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
TypeArgs.type
class TypedTreeCopier extends TreeCopier

Attributes

Supertypes
class TreeCopier
class Object
trait Matchable
class Any
Known subtypes

Inherited classlikes

object AssertNotNull

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

Attributes

Inherited from:
TypedTreeInfo
Supertypes
class Object
trait Matchable
class Any
object ConstantValue

Attributes

Inherited from:
TypedTreeInfo
Supertypes
class Object
trait Matchable
class Any
class DeepFolder[X](f: (X, Tree) => X) extends TreeAccumulator[X]

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

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

Attributes

Inherited from:
Instance
Supertypes
class TreeAccumulator[X]
class Object
trait Matchable
class Any
class MatchingArgs(params: List[Symbol], args: List[Tree])(using x$3: Context)

Attributes

Inherited from:
TreeInfo
Supertypes
class Object
trait Matchable
class Any
object QuotedTypeOf

Attributes

Inherited from:
TypedTreeInfo
Supertypes
class Object
trait Matchable
class Any
class ShallowFolder[X](f: (X, Tree) => X) extends TreeAccumulator[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.

Attributes

Inherited from:
Instance
Supertypes
class TreeAccumulator[X]
class Object
trait Matchable
class Any
object SplicedType

Extractors for type splices

Extractors for type splices

Attributes

Inherited from:
TypedTreeInfo
Supertypes
class Object
trait Matchable
class Any
object TypeDefs

Attributes

Inherited from:
Instance
Supertypes
class Object
trait Matchable
class Any
object ValDefs

Attributes

Inherited from:
Instance
Supertypes
class Object
trait Matchable
class Any
object closure

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

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

Attributes

Inherited from:
TypedTreeInfo
Supertypes
class Object
trait Matchable
class Any
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.

Attributes

Inherited from:
TypedTreeInfo
Supertypes
class Object
trait Matchable
class Any

An extractor for the method of a closure contained the block of the closure, possibly with type ascriptions.

An extractor for the method of a closure contained the block of the closure, possibly with type ascriptions.

Attributes

Inherited from:
TypedTreeInfo
Supertypes
class Object
trait Matchable
class Any

Inherited and Abstract classlikes

abstract class TreeAccumulator[X]

Attributes

Inherited from:
Instance
Supertypes
class Object
trait Matchable
class Any
Known subtypes
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.

Attributes

Inherited from:
Instance
Supertypes
class Object
trait Matchable
class Any
Known subtypes
abstract class TreeMap(val cpy: TreeCopier)

Attributes

Inherited from:
Instance
Supertypes
class Object
trait Matchable
class Any
Known subtypes
abstract class TreeTraverser extends TreeAccumulator[Unit]

Attributes

Inherited from:
Instance
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Inherited types

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Apply = Apply[Type]

Attributes

Inherited from:
Instance
type Assign = Assign[Type]

Attributes

Inherited from:
Instance
type Bind = Bind[Type]

Attributes

Inherited from:
Instance
type Block = Block[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type CaseDef = CaseDef[Type]

Attributes

Inherited from:
Instance
type Closure = Closure[Type]

Attributes

Inherited from:
Instance
type DefDef = DefDef[Type]

Attributes

Inherited from:
Instance
type DefTree = DefTree[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Export = Export[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Hole = Hole[Type]

Attributes

Inherited from:
Instance
type Ident = Ident[Type]

Attributes

Inherited from:
Instance
type If = If[Type]

Attributes

Inherited from:
Instance
type Import = Import[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Inlined = Inlined[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Labeled = Labeled[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Literal = Literal[Type]

Attributes

Inherited from:
Instance
type Match = Match[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type New = New[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Quote = Quote[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type RefTree = RefTree[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Return = Return[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Select = Select[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Splice = Splice[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Super = Super[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Thicket = Thicket[Type]

Attributes

Inherited from:
Instance
type This = This[Type]

Attributes

Inherited from:
Instance
type Tree = Tree[Type]

Attributes

Inherited from:
Instance
type Try = Try[Type]

Attributes

Inherited from:
Instance
type TypTree = TypTree[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type TypeDef = TypeDef[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type Typed = Typed[Type]

Attributes

Inherited from:
Instance
type UnApply = UnApply[Type]

Attributes

Inherited from:
Instance
type ValDef = ValDef[Type]

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
type WhileDo = WhileDo[Type]

Attributes

Inherited from:
Instance

Value members

Concrete methods

def Alternative(trees: List[Tree])(using Context): Alternative
def Annotated(arg: Tree, annot: Tree)(using Context): Annotated
def AnonClass(parents: List[Type], termForwarders: List[(TermName, TermSymbol)], typeMembers: List[(TypeName, TypeBounds)])(using Context): Block

An anonymous class

An anonymous class

new parents { termForwarders; typeAliases }

Value parameters

parents

a non-empty list of class types

termForwarders

a non-empty list of forwarding definitions specified by their name and the definition they forward to.

typeMembers

a possibly-empty list of type members specified by their name and their right hand side. The class has the same owner as the first function in termForwarders. Its position is the union of all symbols in termForwarders.

Attributes

def AnonClass(owner: Symbol, parents: List[Type], coord: Coord)(body: ClassSymbol => List[Tree])(using Context): Block

An anonymous class

An anonymous class

new parents { body }

with the specified owner and position.

Attributes

def AppliedTypeTree(tycon: Tree, args: List[Tree])(using Context): AppliedTypeTree
def Apply(fn: Tree, args: List[Tree])(using Context): Apply
def Assign(lhs: Tree, rhs: Tree)(using Context): Assign
def Bind(sym: Symbol, body: Tree)(using Context): Bind
def BindTyped(sym: TermSymbol, tpe: Type)(using Context): Bind

A pattern corresponding to sym: tpe

A pattern corresponding to sym: tpe

Attributes

def Block(stats: List[Tree], expr: Tree)(using Context): Block
def ByNameTypeTree(result: Tree)(using Context): ByNameTypeTree
def CaseDef(pat: Tree, guard: Tree, body: Tree)(using Context): CaseDef
def ClassDef(cls: ClassSymbol, constr: DefDef, body: List[Tree], superArgs: List[Tree])(using Context): TypeDef
def ClassDefWithParents(cls: ClassSymbol, constr: DefDef, parents: List[Tree], body: List[Tree])(using Context): TypeDef
def Closure(env: List[Tree], meth: Tree, tpt: Tree)(using Context): Closure
def Closure(meth: TermSymbol, rhsFn: (List[List[Tree]]) => Tree, targs: List[Tree], targetType: Type)(using Context): Block

A function def

A function def

vparams => expr

gets expanded to

{ def $anonfun(vparams) = expr; Closure($anonfun) }

where the closure's type is the target type of the expression (FunctionN, unless otherwise specified).

Attributes

def DefDef(sym: TermSymbol, paramss: List[List[Symbol]], resultType: Type, rhs: Tree)(using Context): DefDef
def DefDef(sym: TermSymbol, rhs: Tree)(using Context): DefDef
def DefDef(sym: TermSymbol, rhsFn: (List[List[Tree]]) => Tree)(using Context): DefDef

A DefDef with given method symbol sym.

A DefDef with given method symbol sym.

Attributes

def Export(expr: Tree, selectors: List[ImportSelector])(using Context): Export
def Hole(isTerm: Boolean, idx: Int, args: List[Tree], content: Tree, tpe: Type)(using Context): Hole
def Ident(tp: NamedType)(using Context): Ident
def If(cond: Tree, thenp: Tree, elsep: Tree)(using Context): If
def Import(expr: Tree, selectors: List[ImportSelector])(using Context): Import
def InlineIf(cond: Tree, thenp: Tree, elsep: Tree)(using Context): If
def InlineMatch(selector: Tree, cases: List[CaseDef])(using Context): Match
def Inlined(call: Tree, bindings: List[MemberDef], expansion: Tree)(using Context): Inlined
def JavaSeqLiteral(elems: List[Tree], elemtpt: Tree)(using Context): JavaSeqLiteral
def Labeled(bind: Bind, expr: Tree)(using Context): Labeled
def Labeled(sym: TermSymbol, expr: Tree)(using Context): Labeled
def Lambda(tpe: MethodType, rhsFn: (List[Tree]) => Tree)(using Context): Block

A closure whose anonymous function has the given method type

A closure whose anonymous function has the given method type

Attributes

def LambdaTypeTree(tparams: List[TypeDef], body: Tree)(using Context): LambdaTypeTree
def Literal(const: Constant)(using Context): Literal
def Match(selector: Tree, cases: List[CaseDef])(using Context): Match
def MatchTypeTree(bound: Tree, selector: Tree, cases: List[CaseDef])(using Context): MatchTypeTree
def ModuleDef(sym: TermSymbol, body: List[Tree])(using Context): Thicket

An object def

An object def

object obs extends parents { decls }

gets expanded to

val obj = new obj$ class obj$ extends parents { this: obj.type => decls }

(The following no longer applies: What's interesting here is that the block is well typed (because class obj$ is hoistable), but the type of the obj val is not expressible. What needs to happen in general when inferring the type of a val from its RHS, is: if the type contains a class that has the val itself as owner, then that class is remapped to have the val's owner as owner. Remapping could be done by cloning the class with the new owner and substituting everywhere in the tree. We know that remapping is safe because the only way a local class can appear in the RHS of a val is by being hoisted outside of a block, and the necessary checks are done at this point already.

On the other hand, for method result type inference, if the type of the RHS of a method contains a class owned by the method, this would be an error.)

Attributes

def NamedArg(name: Name, arg: Tree)(using Context): NamedArg
def New(tpt: Tree)(using Context): New
def New(tp: Type)(using Context): New
def New(tp: Type, args: List[Tree])(using Context): Apply

new C(args), calling the primary constructor of C

new C(args), calling the primary constructor of C

Attributes

def New(tp: Type, constr: TermSymbol, args: List[Tree])(using Context): Apply

new C(args), calling given constructor constr of C

new C(args), calling given constructor constr of C

Attributes

def PackageDef(pid: RefTree, stats: List[Tree])(using Context): PackageDef
def Quote(body: Tree, tags: List[Tree])(using Context): Quote
def QuotePattern(bindings: List[Tree], body: Tree, quotes: Tree, proto: Type)(using Context): QuotePattern
def RefinedTypeTree(parent: Tree, refinements: List[Tree], refineCls: ClassSymbol)(using Context): Tree
def Return(expr: Tree, from: Tree)(using Context): Return
def Return(expr: Tree, from: Symbol)(using Context): Return
def Select(qualifier: Tree, name: Name)(using Context): Select
def Select(qualifier: Tree, tp: NamedType)(using Context): Select
def SeqLiteral(elems: List[Tree], elemtpt: Tree)(using Context): SeqLiteral
def Splice(expr: Tree, tpe: Type)(using Context): Splice
def Super(qual: Tree, mix: Ident, mixinClass: Symbol)(using Context): Super
def Super(qual: Tree, mixName: TypeName, mixinClass: Symbol)(using Context): Super
def SyntheticValDef(name: TermName, rhs: Tree, flags: FlagSet)(using Context): ValDef
def This(cls: ClassSymbol)(using Context): This
def Throw(expr: Tree)(using Context): Tree
def Try(block: Tree, cases: List[CaseDef], finalizer: Tree)(using Context): Try
def TypeApply(fn: Tree, args: List[Tree])(using Context): TypeApply
def TypeBoundsTree(lo: Tree, hi: Tree, alias: Tree)(using Context): TypeBoundsTree
def TypeDef(sym: TypeSymbol)(using Context): TypeDef
def TypeTree(tp: Type, inferred: Boolean)(using Context): TypeTree
def Typed(expr: Tree, tpt: Tree)(using Context): Typed
def UnApply(fun: Tree, implicits: List[Tree], patterns: List[Tree], proto: Type)(using Context): UnApply
def Underscore(tp: Type)(using Context): Ident

A _ with given type

A _ with given type

Attributes

def ValDef(sym: TermSymbol, rhs: LazyTree, inferred: Boolean)(using Context): ValDef
def WhileDo(cond: Tree, body: Tree)(using Context): WhileDo
def addInlinedTrees(n: Int)(using Context): Unit

Record inlined trees

Record inlined trees

Attributes

def clsOf(tp: Type)(using Context): Tree

A tree that corresponds to Predef.classOf[$tp] in source

A tree that corresponds to Predef.classOf[$tp] in source

Attributes

def defaultValue(tpe: Type)(using Context): Tree
def desugarIdent(tree: Ident)(using Context): RefTree

Desugar identifier into a select node. Return the tree itself if not possible

Desugar identifier into a select node. Return the tree itself if not possible

Attributes

def desugarIdentPrefix(tree: Ident)(using Context): Tree

Recover identifier prefix (e.g. this) if it exists

Recover identifier prefix (e.g. this) if it exists

Attributes

All enclosing calls that are currently inlined, from innermost to outermost.

All enclosing calls that are currently inlined, from innermost to outermost.

Attributes

def evalOnce(tree: Tree)(within: Tree => Tree)(using Context): Tree

Let bind tree unless tree is at least idempotent

Let bind tree unless tree is at least idempotent

Attributes

Creates the nested higher-kinded pairs type tree representation of the type trees in ts

Creates the nested higher-kinded pairs type tree representation of the type trees in ts

Attributes

The list of select trees that resolve to the same symbols as the ones that are imported by imp.

The list of select trees that resolve to the same symbols as the ones that are imported by imp.

Attributes

def importedSymbols(expr: Tree, name: Name)(using Context): List[Symbol]

The symbols that are imported with expr.name

The symbols that are imported with expr.name

Value parameters

expr

The base of the import statement

name

The name that is being imported.

Attributes

Returns

All the symbols that would be imported with expr.name.

def importedSymbols(imp: Import, selectorPredicate: ImportSelector => Boolean)(using Context): List[Symbol]

All the symbols that are imported by the first selector of imp that matches selectorPredicate.

All the symbols that are imported by the first selector of imp that matches selectorPredicate.

Value parameters

imp

The import statement to analyze

selectorPredicate

A test to find the selector to use.

Attributes

Returns

The symbols imported.

override def inlineContext(tree: Inlined)(using Context): Context

Record an enclosing inlined call. EmptyTree calls (for parameters) cancel the next-enclosing call in the list instead of being added to it. We assume parameters are never nested inside parameters.

Record an enclosing inlined call. EmptyTree calls (for parameters) cancel the next-enclosing call in the list instead of being added to it. We assume parameters are never nested inside parameters.

Attributes

Definition Classes
def joinArgs(targs: List[Tree], argss: List[List[Tree]]): List[List[Tree]]
def letBindUnless(level: PurityLevel, tree: Tree)(within: Tree => Tree)(using Context): Tree

If tree's purity level is less than level, let-bind it so that it gets evaluated only once. I.e. produce a

If tree's purity level is less than level, let-bind it so that it gets evaluated only once. I.e. produce a

{ val x = 'tree ; ~within('x) }

instead of otherwise

~within('tree)

Attributes

def localCtx(tree: Tree)(using Context): Context

The local context to use when traversing trees

The local context to use when traversing trees

Attributes

def localOwner(tree: Tree)(using Context): Symbol

The owner to be used in a local context when traversing a tree

The owner to be used in a local context when traversing a tree

Attributes

def mkList(trees: List[Tree], tpt: Tree)(using Context): Tree

Create a tree representing a list containing all the elements of the argument list. A "list of tree to tree of list" conversion.

Create a tree representing a list containing all the elements of the argument list. A "list of tree to tree of list" conversion.

Value parameters

tpt

the type of the elements of the resulting list.

trees

the elements the list represented by the resulting tree should contain.

Attributes

def needsIdent(tp: Type)(using Context): Boolean
def needsSelect(tp: Type)(using Context): Boolean

Creates the nested pairs type tree representation of the type trees in ts

Creates the nested pairs type tree representation of the type trees in ts

Attributes

def newArray(elemTpe: Type, returnTpe: Type, span: Span, dims: JavaSeqLiteral)(using Context): Tree

A tree representing a newXYZArray operation of the right kind for the given element type in elemTpe. No type arguments or length arguments are given.

A tree representing a newXYZArray operation of the right kind for the given element type in elemTpe. No type arguments or length arguments are given.

Attributes

def pathFor(tp: Type)(using Context): Tree

A path that corresponds to the given type tp. Error if tp is not a refinement of an addressable singleton type.

A path that corresponds to the given type tp. Error if tp is not a refinement of an addressable singleton type.

Attributes

def primitiveConversion(tree: Tree, numericCls: Symbol)(using Context): Tree

Check if the limit on the number of inlined trees has been reached

Check if the limit on the number of inlined trees has been reached

Attributes

def ref(tp: NamedType, needLoad: Boolean)(using Context): Tree

A tree representing the same reference as the given type

A tree representing the same reference as the given type

Attributes

def ref(sym: Symbol)(using Context): Tree
def repeated(trees: List[Tree], tpt: Tree)(using Context): Tree

Convert a list of trees to a vararg-compatible tree. Used to make arguments for methods that accept varargs.

Convert a list of trees to a vararg-compatible tree. Used to make arguments for methods that accept varargs.

Attributes

def runtimeCall(name: TermName, args: List[Tree])(using Context): Tree
def sameTypes(trees: List[Tree], trees1: List[Tree]): Boolean
def seq(stats: List[Tree], expr: Tree)(using Context): Tree

Join stats in front of expr creating a new block if necessary

Join stats in front of expr creating a new block if necessary

Attributes

def singleton(tp: Type, needLoad: Boolean)(using Context): Tree
override 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

Attributes

Definition Classes
def sourceFile(call: Tree)(using Context): SourceFile

The source file where the symbol of the inline method referred to by call is defined

The source file where the symbol of the inline method referred to by call is defined

Attributes

def splitArgs(argss: List[List[Tree]]): (List[Tree], List[List[Tree]])

Split argument clauses into a leading type argument clause if it exists and remaining clauses

Split argument clauses into a leading type argument clause if it exists and remaining clauses

Attributes

def tupleTree(elems: List[Tree])(using Context): Tree

Creates the tuple containing the given elements

Creates the tuple containing the given elements

Attributes

def tupleTypeTree(elems: List[Tree])(using Context): Tree

Creates the tuple type tree representation of the type trees in ts

Creates the tuple type tree representation of the type trees in ts

Attributes

def wrapArray(tree: Tree, elemtp: Type)(using Context): Tree

A tree representing a wrapXYZArray(tree) operation of the right kind for the given element type in elemTpe.

A tree representing a wrapXYZArray(tree) operation of the right kind for the given element type in elemTpe.

Attributes

def wrapArrayMethodName(elemtp: Type)(using Context): TermName

The wrapped array method name for an array of type elemtp

The wrapped array method name for an array of type elemtp

Attributes

Inherited methods

def Thicket(xs: List[Tree])(implicit src: SourceFile): Thicket[Type]

Attributes

Inherited from:
Instance
def Thicket(x1: Tree, x2: Tree, x3: Tree)(implicit src: SourceFile): Thicket

Attributes

Inherited from:
Instance
def Thicket(x1: Tree, x2: Tree)(implicit src: SourceFile): Thicket

Attributes

Inherited from:
Instance
def Thicket(): Thicket

Attributes

Inherited from:
Instance
def allArgss(tree: Tree): List[List[Tree]]

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

Attributes

Inherited from:
TypedTreeInfo
def allArguments(tree: Tree): List[Tree]

All term arguments of an application in a single flattened list

All term arguments of an application in a single flattened list

Attributes

Inherited from:
TreeInfo
def allParamSyms(ddef: DefDef)(using Context): List[Symbol]

All type and value parameter symbols of this DefDef

All type and value parameter symbols of this DefDef

Attributes

Inherited from:
TreeInfo
def appliedCore(tree: Tree): Tree

The tree stripped of the possibly nested applications (term and type). The original tree if it's not an application.

The tree stripped of the possibly nested applications (term and type). The original tree if it's not an application.

Attributes

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 parameters

expectedType

An expected type of the application used to guide overloading resolution

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
def assertAllPositioned(tree: Tree)(using Context): Unit

Attributes

Inherited from:
TypedTreeInfo
def catchesAllOf(cdef: CaseDef, threshold: Type)(using Context): Boolean

Does this CaseDef catch everything of a certain Type?

Does this CaseDef catch everything of a certain Type?

Attributes

Inherited from:
TreeInfo

Does this CaseDef catch Throwable?

Does this CaseDef catch Throwable?

Attributes

Inherited from:
TreeInfo
def closureBody(tree: Tree)(using Context): Tree

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

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

Attributes

Inherited from:
TypedTreeInfo
def constToLiteral(tree: Tree)(using Context): Tree

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

Attributes

Inherited from:
TypedTreeInfo

Decompose a template body into parameters and other statements

Decompose a template body into parameters and other statements

Attributes

Inherited from:
TypedTreeInfo
def defPath(sym: Symbol, root: Tree)(using Context): List[Tree]

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.

Attributes

Inherited from:
TypedTreeInfo
def definedSym(tree: Tree)(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

Attributes

Inherited from:
TypedTreeInfo
def definingStats(sym: Symbol)(using Context): List[Tree]

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.

Attributes

Inherited from:
TypedTreeInfo
def exprPurity(tree: Tree)(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.

Attributes

Inherited from:
TypedTreeInfo
def firstConstructor(stats: List[Tree]): Tree

The first constructor definition in stats

The first constructor definition in stats

Attributes

Inherited from:
TreeInfo
def flatTree(xs: List[Tree])(implicit src: SourceFile): Tree

Attributes

Inherited from:
Instance
def forallResults(tree: Tree, p: Tree => 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.

Attributes

Inherited from:
TreeInfo
def funPart(tree: Tree): Tree

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

Attributes

Inherited from:
TypedTreeInfo

Is tree explicitly parameterized with type arguments?

Is tree explicitly parameterized with type arguments?

Attributes

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?

Attributes

Inherited from:
TreeInfo
def isBackquoted(tree: Tree): Boolean

Is tree a backquoted identifier or definition

Is tree a backquoted identifier or definition

Attributes

Inherited from:
TreeInfo
def isByNameType(tree: Tree)(using Context): Boolean

Is tree a type tree of the form => T or (under pureFunctions) {refs}-> T?

Is tree a type tree of the form => T or (under pureFunctions) {refs}-> T?

Attributes

Inherited from:
TreeInfo
def isCatchCase(cdef: CaseDef)(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?

Attributes

Inherited from:
TypedTreeInfo

Attributes

Inherited from:
TreeInfo

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

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

Attributes

Inherited from:
TreeInfo
def isEtaExpansion(mdef: DefDef)(using Context): Boolean

Is mdef an eta-expansion of a method reference? To recognize this, we use the following criterion: A method definition is an eta expansion, if it contains at least one term paramter, the parameter has a zero extent span, and the right hand side is either an application or a closure with' an anonymous method that's itself characterized as an eta expansion.

Is mdef an eta-expansion of a method reference? To recognize this, we use the following criterion: A method definition is an eta expansion, if it contains at least one term paramter, the parameter has a zero extent span, and the right hand side is either an application or a closure with' an anonymous method that's itself characterized as an eta expansion.

Attributes

Inherited from:
TypedTreeInfo
def isExtMethodApply(tree: Tree)(using Context): Boolean

Attributes

Inherited from:
TypedTreeInfo

Is this case guarded?

Is this case guarded?

Attributes

Inherited from:
TreeInfo
def isIdempotentExpr(tree: Tree)(using Context): Boolean

Attributes

Inherited from:
TypedTreeInfo
def isIdempotentPath(tree: Tree)(using Context): Boolean

Attributes

Inherited from:
TypedTreeInfo
def isIdempotentRef(tree: Tree)(using Context): Boolean

Attributes

Inherited from:
TypedTreeInfo
def isOpAssign(tree: Tree): Boolean

Attributes

Inherited from:
TreeInfo
def isPath(tree: Tree): Boolean

Is tree a path?

Is tree a path?

Attributes

Inherited from:
TreeInfo
def isPureApply(tree: Tree, fn: Tree)(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.

Attributes

Inherited from:
TypedTreeInfo
def isPureBinding(tree: Tree)(using Context): Boolean

Attributes

Inherited from:
TypedTreeInfo
def isPureExpr(tree: Tree)(using Context): Boolean

Attributes

Inherited from:
TypedTreeInfo
def isPurePath(tree: Tree)(using Context): Boolean

Attributes

Inherited from:
TypedTreeInfo
def isPureRef(tree: Tree)(using Context): Boolean

Attributes

Inherited from:
TypedTreeInfo

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

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

Attributes

Inherited from:
TreeInfo
def isSelf(tree: Tree, enclClass: Symbol)(using Context): Boolean

Is tree a this node which belongs to enclClass?

Is tree a this node which belongs to enclClass?

Attributes

Inherited from:
TypedTreeInfo

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?

Attributes

Inherited from:
TreeInfo

Attributes

Inherited from:
TreeInfo

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?

Attributes

Inherited from:
TypedTreeInfo

Is tree a super constructor call?

Is tree a super constructor call?

Attributes

Inherited from:
TreeInfo

Attributes

Inherited from:
TreeInfo

Attributes

Inherited from:
Instance
def isThisTypeResult(tree: Tree)(using Context): Boolean

Is tree an application with result this.type? Accept b.addOne(x) and also xs(i) += x where the op is an assignment operator.

Is tree an application with result this.type? Accept b.addOne(x) and also xs(i) += x where the op is an assignment operator.

Attributes

Inherited from:
TreeInfo

Attributes

Inherited from:
TreeInfo
def isUsingClause(params: ParamClause)(using Context): Boolean

Is this parameter list a using clause?

Is this parameter list a using clause?

Attributes

Inherited from:
TreeInfo

Attributes

Inherited from:
TreeInfo

Is tree a variable pattern?

Is tree a variable pattern?

Attributes

Inherited from:
TreeInfo
def isVariableOrGetter(tree: Tree)(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?

Attributes

Inherited from:
TypedTreeInfo
def isWildcardArg(tree: Tree): Boolean

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

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

Attributes

Inherited from:
TreeInfo
def isWildcardStarArg(tree: Tree)(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.

Attributes

Inherited from:
TreeInfo

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

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

Attributes

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.

Attributes

Inherited from:
Instance

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.

Attributes

Inherited from:
TreeInfo
def localSyms(stats: List[Tree])(using Context): List[Symbol]

The symbols defined locally in a statement list

The symbols defined locally in a statement list

Attributes

Inherited from:
TypedTreeInfo
def mayBeVarGetter(sym: Symbol)(using Context): Boolean

Is symbol potentially a getter of a mutable variable?

Is symbol potentially a getter of a mutable variable?

Attributes

Inherited from:
TypedTreeInfo
def methPart(tree: Tree): Tree

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

Attributes

Inherited from:
TreeInfo
def numArgs(tree: Tree): Int

The number of arguments in an application

The number of arguments in an application

Attributes

Inherited from:
TreeInfo
def parentsKind(parents: List[Tree])(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.

Attributes

Inherited from:
TreeInfo
def patVars(tree: Tree)(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.

Attributes

Inherited from:
TypedTreeInfo
def qualifier(tree: Tree)(using Context): Tree

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.

Attributes

Inherited from:
TypedTreeInfo
def refPurity(tree: Tree)(using Context): PurityLevel

The purity level of this reference.

The purity level of this reference.

Attributes

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

Inherited from:
TypedTreeInfo
def rename(tree: NameTree, newName: Name)(using Context): tree.ThisTree[Type]

Attributes

Inherited from:
Instance
def resolveConstructor(atp: Type, args: List[Tree])(using Context): Tree

Attributes

Inherited from:
Instance
def rhsOfEtaExpansion(mdef: DefDef)(using Context): Tree

Attributes

Inherited from:
TypedTreeInfo
def sliceTopLevel(tree: Tree, cls: ClassSymbol)(using Context): List[Tree]

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

Attributes

Inherited from:
TypedTreeInfo
final def splitAtSuper(constrStats: List[Tree])(implicit ctx: Context): (List[Tree], List[Tree])

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)

Attributes

Inherited from:
TypedTreeInfo
def statPurity(tree: Tree)(using Context): PurityLevel

The purity level of this statement.

The purity level of this statement.

Attributes

Returns

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

Inherited from:
TypedTreeInfo
def stripAnnotated(tree: Tree): Tree

Attributes

Inherited from:
TreeInfo
def stripApply(tree: Tree): Tree

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.

Attributes

Inherited from:
TreeInfo
def stripBlock(tree: Tree): Tree

If this is a block, its expression part

If this is a block, its expression part

Attributes

Inherited from:
TreeInfo
def stripByNameType(tree: Tree)(using Context): Tree

Strip => T to T and (under pureFunctions) {refs}-> T to T

Strip => T to T and (under pureFunctions) {refs}-> T to T

Attributes

Inherited from:
TreeInfo
def stripCast(tree: Tree)(using Context): Tree

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

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

Attributes

Inherited from:
TypedTreeInfo
def stripInlined(tree: Tree): Tree

Attributes

Inherited from:
TreeInfo
def stripTyped(tree: Tree): Tree

Attributes

Inherited from:
TreeInfo
def termArgss(tree: Tree): List[List[Tree]]

The term arguments of a possibly curried call

The term arguments of a possibly curried call

Attributes

Inherited from:
TreeInfo

Attributes

Inherited from:
Instance

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.

Attributes

Inherited from:
TypedTreeInfo
def transformCtx(tree: Tree)(using Context): Context

The context to use when transforming a tree. It ensures that the source is correct, and that the local context is used if that's necessary for transforming the whole tree. TODO: ensure transform is always called with the correct context as argument

The context to use when transforming a tree. It ensures that the source is correct, and that the local context is used if that's necessary for transforming the whole tree. TODO: ensure transform is always called with the correct context as argument

Attributes

See also
Inherited from:
Instance
def tupleArgs(tree: Tree)(using Context): List[Tree]

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.

Attributes

Inherited from:
TypedTreeInfo
def typeArgss(tree: Tree): List[List[Tree]]

The type arguments of a possibly curried call

The type arguments of a possibly curried call

Attributes

Inherited from:
TreeInfo
def unbind(x: Tree): Tree

The underlying pattern ignoring any bindings

The underlying pattern ignoring any bindings

Attributes

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

Attributes

Inherited from:
TreeInfo

Concrete fields

override val cpy: TypedTreeCopier
val sameStats: (List[Tree]) => Context ?=> List[Tree]

Inherited fields

Attributes

Inherited from:
Instance

Attributes

Inherited from:
Instance
val isNamedArg: Any => Boolean

Attributes

Inherited from:
TreeInfo

Extensions

Extensions

extension (trees: List[Tree])
inline def flattenedMapConserve(inline f: Tree => Tree): List[Tree]

Equivalent (but faster) to

Equivalent (but faster) to

flatten(trees.mapConserve(op))

assuming that trees does not contain Thickets to start with.

Attributes

inline def mapStatements[T](exprOwner: Symbol, inline op: Tree => Context ?=> Tree, inline wrapResult: (List[Tree]) => Context ?=> T)(using Context): T

Transform statements while maintaining import contexts and expression contexts in the same way as Typer does. The code addresses additional concerns:

Transform statements while maintaining import contexts and expression contexts in the same way as Typer does. The code addresses additional concerns:

  • be tail-recursive where possible
  • don't re-allocate trees where nothing has changed

Attributes

extension (xs: List[Tree])
def tpes: List[Type]

Inherited 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

Attributes

Inherited from:
TypedTreeInfo
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

Attributes

Inherited from:
TypedTreeInfo
extension (tree: Quote)
def bodyType(using Context): Type

Type of the quoted expression as seen from outside the quote

Type of the quoted expression as seen from outside the quote

Attributes

Inherited from:
TypedTreeInfo
extension (tree: QuotePattern)
def bodyType(using Context): Type

Type of the quoted pattern

Type of the quoted pattern

Attributes

Inherited from:
TypedTreeInfo

Implicits

Implicits

final implicit def TreeOps[ThisTree <: Tree](tree: ThisTree): TreeOps[ThisTree]