W3cubDocs

/Scala 2.12 Reflection

Trait scala.reflect.api.Trees

trait Trees extends AnyRef

EXPERIMENTAL

This trait defines the node types used in Scala abstract syntax trees (AST) and operations on them.

Trees are the basis for Scala's abstract syntax that is used to represent programs. They are also called abstract syntax trees and commonly abbreviated as ASTs.

In Scala reflection, APIs that produce or use Trees are:

  • Annotations which use trees to represent their arguments, exposed in Annotation.scalaArgs.
  • reify, a special method on scala.reflect.api.Universe that takes an expression and returns an AST which represents the expression.
  • Macros and runtime compilation with toolboxes which both use trees as their program representation medium.

Trees are immutable, except for three fields pos, symbol, and tpe, which are assigned when a tree is typechecked to attribute it with the information gathered by the typechecker.

Examples

The following creates an AST representing a literal 5 in Scala source code:

Literal(Constant(5))

The following creates an AST representing print("Hello World"):

Apply(Select(Select(This(TypeName("scala")), TermName("Predef")), TermName("print")), List(Literal(Constant("Hello World"))))

The following creates an AST from a literal 5, and then uses showRaw to print it in a readable format.

import scala.reflect.runtime.universe.{ reify, showRaw }
print( showRaw( reify{5}.tree ) )` // prints Literal(Constant(5))

For more information about Trees, see the Reflection Guide: Symbols, Trees, Types.

Self Type
Universe
Source
Trees.scala
Linear Supertypes
Known Subclasses

Type Members

abstract type Alternative >: Null <: Universe.AlternativeApi with Universe.TermTree

Alternatives of patterns.

Eliminated by compiler phases Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher), except for occurrences in encoded Switch stmt (i.e. remaining Match(CaseDef(...)))

trait AlternativeApi extends Universe.TermTreeApi

abstract class AlternativeExtractor extends AnyRef

An extractor class to create and pattern match with syntax Alternative(trees). This AST node corresponds to the following Scala code:

pat1 | ... | patn

abstract type Annotated >: Null <: Universe.AnnotatedApi with Universe.Tree

A tree that has an annotation attached to it. Only used for annotated types and annotation ascriptions, annotations on definitions are stored in the Modifiers. Eliminated by typechecker (typedAnnotated), the annotations are then stored in an AnnotatedType.

trait AnnotatedApi extends Universe.TreeApi

abstract class AnnotatedExtractor extends AnyRef

An extractor class to create and pattern match with syntax Annotated(annot, arg). This AST node corresponds to the following Scala code:

arg @annot // for types arg: @annot // for exprs

abstract type AppliedTypeTree >: Null <: Universe.AppliedTypeTreeApi with Universe.TypTree

trait AppliedTypeTreeApi extends Universe.TypTreeApi

abstract class AppliedTypeTreeExtractor extends AnyRef

An extractor class to create and pattern match with syntax AppliedTypeTree(tpt, args). This AST node corresponds to the following Scala code:

tpt[args]

Should only be used with tpt nodes which are types, i.e. which have isType returning true. Otherwise TypeApply should be used instead.

List[Int] as in val x: List[Int] = ??? // represented as AppliedTypeTree(Ident(<List>), List(TypeTree(<Int>)))

def foo[T] = ??? foo[Int] // represented as TypeApply(Ident(<foo>), List(TypeTree(<Int>)))

abstract type Apply >: Null <: Universe.ApplyApi with Universe.GenericApply

trait ApplyApi extends Universe.GenericApplyApi

abstract class ApplyExtractor extends AnyRef

An extractor class to create and pattern match with syntax Apply(fun, args). This AST node corresponds to the following Scala code:

fun(args)

For instance:

fun[targs](args)

Is expressed as:

Apply(TypeApply(fun, targs), args)

abstract type Assign >: Null <: Universe.AssignApi with Universe.TermTree

trait AssignApi extends Universe.TermTreeApi

abstract class AssignExtractor extends AnyRef

An extractor class to create and pattern match with syntax Assign(lhs, rhs). This AST node corresponds to the following Scala code:

lhs = rhs

abstract type AssignOrNamedArg >: Null <: Universe.AssignOrNamedArgApi with Universe.TermTree

Either an assignment or a named argument. Only appears in argument lists, eliminated by compiler phase typecheck (doTypedApply), resurrected by reifier.

trait AssignOrNamedArgApi extends Universe.TermTreeApi

abstract class AssignOrNamedArgExtractor extends AnyRef

An extractor class to create and pattern match with syntax AssignOrNamedArg(lhs, rhs). This AST node corresponds to the following Scala code:

m.f(lhs = rhs)
@annotation(lhs = rhs)

abstract type Bind >: Null <: Universe.BindApi with Universe.DefTree

Bind a variable to a rhs pattern.

Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher).

trait BindApi extends Universe.DefTreeApi

abstract class BindExtractor extends AnyRef

An extractor class to create and pattern match with syntax Bind(name, body). This AST node corresponds to the following Scala code:

pat*

abstract type Block >: Null <: Universe.BlockApi with Universe.TermTree

trait BlockApi extends Universe.TermTreeApi

abstract class BlockExtractor extends AnyRef

An extractor class to create and pattern match with syntax Block(stats, expr). This AST node corresponds to the following Scala code:

{ stats; expr }

If the block is empty, the expr is set to Literal(Constant(())).

abstract type CaseDef >: Null <: Universe.CaseDefApi with Universe.Tree

Case clause in a pattern match. (except for occurrences in switch statements). Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher)

trait CaseDefApi extends Universe.TreeApi

abstract class CaseDefExtractor extends AnyRef

An extractor class to create and pattern match with syntax CaseDef(pat, guard, body). This AST node corresponds to the following Scala code:

case pat if guard => body

If the guard is not present, the guard is set to EmptyTree. If the body is not specified, the body is set to Literal(Constant(()))

abstract type ClassDef >: Null <: Universe.ClassDefApi with Universe.ImplDef

trait ClassDefApi extends Universe.ImplDefApi

abstract class ClassDefExtractor extends AnyRef

An extractor class to create and pattern match with syntax ClassDef(mods, name, tparams, impl). This AST node corresponds to the following Scala code:

mods class name [tparams] impl

Where impl stands for:

extends parents { defs }

abstract type CompoundTypeTree >: Null <: Universe.CompoundTypeTreeApi with Universe.TypTree

Intersection type <parent1> with ... with <parentN> { <decls> }, eliminated by RefCheck

trait CompoundTypeTreeApi extends Universe.TypTreeApi

abstract class CompoundTypeTreeExtractor extends AnyRef

An extractor class to create and pattern match with syntax CompoundTypeTree(templ). This AST node corresponds to the following Scala code:

parent1 with ... with parentN { refinement }

abstract type DefDef >: Null <: Universe.DefDefApi with Universe.ValOrDefDef

trait DefDefApi extends Universe.ValOrDefDefApi

abstract class DefDefExtractor extends AnyRef

An extractor class to create and pattern match with syntax DefDef(mods, name, tparams, vparamss, tpt, rhs). This AST node corresponds to the following Scala code:

mods def name[tparams](vparams_1)...(vparams_n): tpt = rhs

If the return type is not specified explicitly (i.e. is meant to be inferred), this is expressed by having tpt set to TypeTree() (but not to an EmptyTree!).

abstract type DefTree >: Null <: Universe.DefTreeApi with Universe.SymTree with Universe.NameTree

trait DefTreeApi extends Universe.SymTreeApi with Universe.NameTreeApi

abstract type ExistentialTypeTree >: Null <: Universe.ExistentialTypeTreeApi with Universe.TypTree

trait ExistentialTypeTreeApi extends Universe.TypTreeApi

abstract class ExistentialTypeTreeExtractor extends AnyRef

An extractor class to create and pattern match with syntax ExistentialTypeTree(tpt, whereClauses). This AST node corresponds to the following Scala code:

tpt forSome { whereClauses }

abstract type Function >: Null <: Universe.FunctionApi with Universe.TermTree with Universe.SymTree

trait FunctionApi extends Universe.TermTreeApi with Universe.SymTreeApi

abstract class FunctionExtractor extends AnyRef

An extractor class to create and pattern match with syntax Function(vparams, body). This AST node corresponds to the following Scala code:

vparams => body

The symbol of a Function is a synthetic TermSymbol. It is the owner of the function's parameters.

abstract type GenericApply >: Null <: Universe.GenericApplyApi with Universe.TermTree

trait GenericApplyApi extends Universe.TermTreeApi

abstract type Ident >: Null <: Universe.IdentApi with Universe.RefTree

trait IdentApi extends Universe.RefTreeApi

abstract class IdentExtractor extends AnyRef

An extractor class to create and pattern match with syntax Ident(qual, name). This AST node corresponds to the following Scala code:

name

Type checker converts idents that refer to enclosing fields or methods to selects. For example, name ==> this.name

abstract type If >: Null <: Universe.IfApi with Universe.TermTree

trait IfApi extends Universe.TermTreeApi

abstract class IfExtractor extends AnyRef

An extractor class to create and pattern match with syntax If(cond, thenp, elsep). This AST node corresponds to the following Scala code:

if (cond) thenp else elsep

If the alternative is not present, the elsep is set to Literal(Constant(())).

abstract type ImplDef >: Null <: Universe.ImplDefApi with Universe.MemberDef

trait ImplDefApi extends Universe.MemberDefApi

abstract type Import >: Null <: Universe.ImportApi with Universe.SymTree

trait ImportApi extends Universe.SymTreeApi

abstract class ImportExtractor extends AnyRef

An extractor class to create and pattern match with syntax Import(expr, selectors). This AST node corresponds to the following Scala code:

import expr.{selectors}

Selectors are a list of ImportSelectors, which conceptually are pairs of names (from, to). The last (and maybe only name) may be a nme.WILDCARD. For instance:

import qual.{x, y => z, _}

Would be represented as:

Import(qual, List(("x", "x"), ("y", "z"), (WILDCARD, null)))

The symbol of an Import is an import symbol @see Symbol.newImport. It's used primarily as a marker to check that the import has been typechecked.

abstract type ImportSelector >: Null <: Universe.ImportSelectorApi

Import selector (not a tree, but a component of the Import tree)

Representation of an imported name its optional rename and their optional positions

Eliminated by typecheck.

trait ImportSelectorApi extends AnyRef

abstract class ImportSelectorExtractor extends AnyRef

An extractor class to create and pattern match with syntax ImportSelector(name:, namePos, rename, renamePos). This is not an AST node, it is used as a part of the Import node.

abstract type LabelDef >: Null <: Universe.LabelDefApi with Universe.DefTree with Universe.TermTree

A labelled expression. Not expressible in language syntax, but generated by the compiler to simulate while/do-while loops, and also by the pattern matcher.

The label acts much like a nested function, where params represents the incoming parameters. The symbol given to the LabelDef should have a MethodType, as if it were a nested function.

Jumps are apply nodes attributed with a label's symbol. The arguments from the apply node will be passed to the label and assigned to the Idents.

Forward jumps within a block are allowed.

trait LabelDefApi extends Universe.DefTreeApi with Universe.TermTreeApi

abstract class LabelDefExtractor extends AnyRef

An extractor class to create and pattern match with syntax LabelDef(name, params, rhs).

This AST node does not have direct correspondence to Scala code. It is used for tailcalls and like. For example, while/do are desugared to label defs as follows:

while (cond) body ==> LabelDef($L, List(), if (cond) { body; L$() } else ())
do body while (cond) ==> LabelDef($L, List(), body; if (cond) L$() else ())

abstract type Literal >: Null <: Universe.LiteralApi with Universe.TermTree

trait LiteralApi extends Universe.TermTreeApi

abstract class LiteralExtractor extends AnyRef

An extractor class to create and pattern match with syntax Literal(value). This AST node corresponds to the following Scala code:

value

abstract type Match >: Null <: Universe.MatchApi with Universe.TermTree

- Pattern matching expression (before compiler phase explicitouter before 2.10 / patmat from 2.10)

    Switch statements (after compiler phase explicitouter before 2.10 / patmat from 2.10)

After compiler phase explicitouter before 2.10 / patmat from 2.10, cases will satisfy the following constraints:

    all guards are EmptyTree,all patterns will be either Literal(Constant(x:Int)) or Alternative(lit|...|lit)except for an "otherwise" branch, which has pattern Ident(nme.WILDCARD)

trait MatchApi extends Universe.TermTreeApi

abstract class MatchExtractor extends AnyRef

An extractor class to create and pattern match with syntax Match(selector, cases). This AST node corresponds to the following Scala code:

selector match { cases }

Match is also used in pattern matching assignments like val (foo, bar) = baz.

abstract type MemberDef >: Null <: Universe.MemberDefApi with Universe.DefTree

trait MemberDefApi extends Universe.DefTreeApi

abstract type Modifiers >: Null <: Universe.ModifiersApi

abstract class ModifiersApi extends AnyRef

abstract class ModifiersExtractor extends AnyRef

An extractor class to create and pattern match with syntax Modifiers(flags, privateWithin, annotations). Modifiers encapsulate flags, visibility annotations and Scala annotations for member definitions.

abstract type ModuleDef >: Null <: Universe.ModuleDefApi with Universe.ImplDef

An object definition, e.g. object Foo. Internally, objects are quite frequently called modules to reduce ambiguity. Eliminated by compiler phase refcheck.

trait ModuleDefApi extends Universe.ImplDefApi

abstract class ModuleDefExtractor extends AnyRef

An extractor class to create and pattern match with syntax ModuleDef(mods, name, impl). This AST node corresponds to the following Scala code:

mods object name impl

Where impl stands for:

extends parents { defs }

abstract type NameTree >: Null <: Universe.NameTreeApi with Universe.Tree

A tree that carries a name, e.g. by defining it (DefTree) or by referring to it (RefTree).

trait NameTreeApi extends Universe.TreeApi

abstract type New >: Null <: Universe.NewApi with Universe.TermTree

trait NewApi extends Universe.TermTreeApi

abstract class NewExtractor extends AnyRef

An extractor class to create and pattern match with syntax New(tpt). This AST node corresponds to the following Scala code:

new T

This node always occurs in the following context:

(new tpt).<init>[targs](args)

For example, an AST representation of:

new Example[Int](2)(3)

is the following code:

Apply( Apply( TypeApply( Select(New(TypeTree(typeOf[Example])), nme.CONSTRUCTOR) TypeTree(typeOf[Int])), List(Literal(Constant(2)))), List(Literal(Constant(3))))

abstract type PackageDef >: Null <: Universe.PackageDefApi with Universe.MemberDef

trait PackageDefApi extends Universe.MemberDefApi

abstract class PackageDefExtractor extends AnyRef

An extractor class to create and pattern match with syntax PackageDef(pid, stats). This AST node corresponds to the following Scala code:

package pid { stats }

abstract type RefTree >: Null <: Universe.RefTreeApi with Universe.SymTree with Universe.NameTree

A tree which references a symbol-carrying entity. References one, as opposed to defining one; definitions are in DefTrees.

trait RefTreeApi extends Universe.SymTreeApi with Universe.NameTreeApi

abstract class RefTreeExtractor extends AnyRef

An extractor class to create and pattern match with syntax RefTree(qual, name). This AST node corresponds to either Ident, Select or SelectFromTypeTree.

abstract type Return >: Null <: Universe.ReturnApi with Universe.SymTree with Universe.TermTree

trait ReturnApi extends Universe.TermTreeApi

abstract class ReturnExtractor extends AnyRef

An extractor class to create and pattern match with syntax Return(expr). This AST node corresponds to the following Scala code:

return expr

The symbol of a Return node is the enclosing method.

abstract type Select >: Null <: Universe.SelectApi with Universe.RefTree

A member selection <qualifier> . <name>

trait SelectApi extends Universe.RefTreeApi

abstract class SelectExtractor extends AnyRef

An extractor class to create and pattern match with syntax Select(qual, name). This AST node corresponds to the following Scala code:

qualifier.selector

Should only be used with qualifier nodes which are terms, i.e. which have isTerm returning true. Otherwise SelectFromTypeTree should be used instead.

foo.Bar // represented as Select(Ident(<foo>), <Bar>) Foo#Bar // represented as SelectFromTypeTree(Ident(<Foo>), <Bar>)

abstract type SelectFromTypeTree >: Null <: Universe.SelectFromTypeTreeApi with Universe.TypTree with Universe.RefTree

trait SelectFromTypeTreeApi extends Universe.TypTreeApi with Universe.RefTreeApi

abstract class SelectFromTypeTreeExtractor extends AnyRef

An extractor class to create and pattern match with syntax SelectFromTypeTree(qualifier, name). This AST node corresponds to the following Scala code:

qualifier # selector

Note: a path-dependent type p.T is expressed as p.type # T

Should only be used with qualifier nodes which are types, i.e. which have isType returning true. Otherwise Select should be used instead.

Foo#Bar // represented as SelectFromTypeTree(Ident(<Foo>), <Bar>) foo.Bar // represented as Select(Ident(<foo>), <Bar>)

abstract type SingletonTypeTree >: Null <: Universe.SingletonTypeTreeApi with Universe.TypTree

trait SingletonTypeTreeApi extends Universe.TypTreeApi

abstract class SingletonTypeTreeExtractor extends AnyRef

An extractor class to create and pattern match with syntax SingletonTypeTree(ref). This AST node corresponds to the following Scala code:

ref.type

abstract type Star >: Null <: Universe.StarApi with Universe.TermTree

Repetition of pattern.

Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher).

trait StarApi extends Universe.TermTreeApi

abstract class StarExtractor extends AnyRef

An extractor class to create and pattern match with syntax Star(elem). This AST node corresponds to the following Scala code:

pat*

abstract type Super >: Null <: Universe.SuperApi with Universe.TermTree

Super reference, where qual is the corresponding this reference. A super reference C.super[M] is represented as Super(This(C), M).

trait SuperApi extends Universe.TermTreeApi

abstract class SuperExtractor extends AnyRef

An extractor class to create and pattern match with syntax Super(qual, mix). This AST node corresponds to the following Scala code:

C.super[M]

Which is represented as:

Super(This(C), M)

If mix is empty, it is tpnme.EMPTY.

The symbol of a Super is the class _from_ which the super reference is made. For instance in C.super(...), it would be C.

abstract type SymTree >: Null <: Universe.SymTreeApi with Universe.Tree

A tree that carries a symbol, e.g. by defining it (DefTree) or by referring to it (RefTree). Such trees start their life naked, returning NoSymbol, but after being typechecked without errors they hold non-empty symbols.

trait SymTreeApi extends Universe.TreeApi

abstract type Template >: Null <: Universe.TemplateApi with Universe.SymTree

trait TemplateApi extends Universe.SymTreeApi

abstract class TemplateExtractor extends AnyRef

An extractor class to create and pattern match with syntax Template(parents, self, body). This AST node corresponds to the following Scala code:

extends parents { self => body }

In case when the self-type annotation is missing, it is represented as an empty value definition with nme.WILDCARD as name and NoType as type.

The symbol of a template is a local dummy. @see Symbol.newLocalDummy The owner of the local dummy is the enclosing trait or class. The local dummy is itself the owner of any local blocks. For example:

class C { def foo { // owner is C def bar // owner is local dummy } }

abstract type TermTree >: Null <: Universe.TermTreeApi with Universe.Tree

A tree for a term. Not all trees representing terms are TermTrees; use isTerm to reliably identify terms.

trait TermTreeApi extends Universe.TreeApi

abstract type This >: Null <: Universe.ThisApi with Universe.TermTree with Universe.SymTree

trait ThisApi extends Universe.TermTreeApi with Universe.SymTreeApi

abstract class ThisExtractor extends AnyRef

An extractor class to create and pattern match with syntax This(qual). This AST node corresponds to the following Scala code:

qual.this

The symbol of a This is the class to which the this refers. For instance in C.this, it would be C.

abstract type Throw >: Null <: Universe.ThrowApi with Universe.TermTree

trait ThrowApi extends Universe.TermTreeApi

abstract class ThrowExtractor extends AnyRef

An extractor class to create and pattern match with syntax Throw(expr). This AST node corresponds to the following Scala code:

throw expr

abstract class Transformer extends AnyRef

class Traverser extends AnyRef

abstract type Tree >: Null <: Universe.TreeApi

trait TreeApi extends Product

The API that all trees support. The main source of information about trees is the scala.reflect.api.Trees page.

abstract type TreeCopier >: Null <: Universe.TreeCopierOps

abstract class TreeCopierOps extends AnyRef

abstract type Try >: Null <: Universe.TryApi with Universe.TermTree

trait TryApi extends Universe.TermTreeApi

abstract class TryExtractor extends AnyRef

An extractor class to create and pattern match with syntax Try(block, catches, finalizer). This AST node corresponds to the following Scala code:

try block catch { catches } finally finalizer

If the finalizer is not present, the finalizer is set to EmptyTree.

abstract type TypTree >: Null <: Universe.TypTreeApi with Universe.Tree

A tree for a type. Not all trees representing types are TypTrees; use isType to reliably identify types.

trait TypTreeApi extends Universe.TreeApi

abstract type TypeApply >: Null <: Universe.TypeApplyApi with Universe.GenericApply

trait TypeApplyApi extends Universe.GenericApplyApi

abstract class TypeApplyExtractor extends AnyRef

An extractor class to create and pattern match with syntax TypeApply(fun, args). This AST node corresponds to the following Scala code:

fun[args]

Should only be used with fun nodes which are terms, i.e. which have isTerm returning true. Otherwise AppliedTypeTree should be used instead.

def foo[T] = ??? foo[Int] // represented as TypeApply(Ident(<foo>), List(TypeTree(<Int>)))

List[Int] as in val x: List[Int] = ??? // represented as AppliedTypeTree(Ident(<List>), List(TypeTree(<Int>)))

abstract type TypeBoundsTree >: Null <: Universe.TypeBoundsTreeApi with Universe.TypTree

trait TypeBoundsTreeApi extends Universe.TypTreeApi

abstract class TypeBoundsTreeExtractor extends AnyRef

An extractor class to create and pattern match with syntax TypeBoundsTree(lo, hi). This AST node corresponds to the following Scala code:

>: lo <: hi

abstract type TypeDef >: Null <: Universe.TypeDefApi with Universe.MemberDef

An abstract type, a type parameter, or a type alias. Eliminated by erasure.

trait TypeDefApi extends Universe.MemberDefApi

abstract class TypeDefExtractor extends AnyRef

An extractor class to create and pattern match with syntax TypeDef(mods, name, tparams, rhs). This AST node corresponds to the following Scala code:

mods type name[tparams] = rhs

mods type name[tparams] >: lo <: hi

First usage illustrates TypeDefs representing type aliases and type parameters. Second usage illustrates TypeDefs representing abstract types, where lo and hi are both TypeBoundsTrees and Modifier.deferred is set in mods.

abstract type TypeTree >: Null <: Universe.TypeTreeApi with Universe.TypTree

A synthetic tree holding an arbitrary type. Not to be confused with with TypTree, the trait for trees that are only used for type trees. TypeTree's are inserted in several places, but most notably in RefCheck, where the arbitrary type trees are all replaced by TypeTree's.

trait TypeTreeApi extends Universe.TypTreeApi

abstract class TypeTreeExtractor extends AnyRef

An extractor class to create and pattern match with syntax TypeTree(). This AST node does not have direct correspondence to Scala code, and is emitted by everywhere when we want to wrap a Type in a Tree.

abstract type Typed >: Null <: Universe.TypedApi with Universe.TermTree

trait TypedApi extends Universe.TermTreeApi

abstract class TypedExtractor extends AnyRef

An extractor class to create and pattern match with syntax Typed(expr, tpt). This AST node corresponds to the following Scala code:

expr: tpt

abstract type UnApply >: Null <: Universe.UnApplyApi with Universe.TermTree

Used to represent unapply methods in pattern matching.

For example:

2 match { case Foo(x) => x }

Is represented as:

Match(
  Literal(Constant(2)),
  List(
    CaseDef(
      UnApply(
        // a dummy node that carries the type of unapplication to patmat
        // the <unapply-selector> here doesn't have an underlying symbol
        // it only has a type assigned, therefore after `untypecheck` this tree is no longer typeable
        Apply(Select(Ident(Foo), TermName("unapply")), List(Ident(TermName("<unapply-selector>")))),
        // arguments of the unapply => nothing synthetic here
        List(Bind(TermName("x"), Ident(nme.WILDCARD)))),
      EmptyTree,
      Ident(TermName("x")))))

Introduced by typer. Eliminated by compiler phases patmat (in the new pattern matcher of 2.10) or explicitouter (in the old pre-2.10 pattern matcher).

trait UnApplyApi extends Universe.TermTreeApi

abstract class UnApplyExtractor extends AnyRef

An extractor class to create and pattern match with syntax UnApply(fun, args). This AST node does not have direct correspondence to Scala code, and is introduced when typechecking pattern matches and try blocks.

abstract type ValDef >: Null <: Universe.ValDefApi with Universe.ValOrDefDef

Broadly speaking, a value definition. All these are encoded as ValDefs:

    immutable values, e.g. "val x"mutable values, e.g. "var x" - the MUTABLE flag set in modslazy values, e.g. "lazy val x" - the LAZY flag set in modsmethod parameters, see vparamss in scala.reflect.api.Trees#DefDef - the PARAM flag is set in modsexplicit self-types, e.g. class A { self: Bar => }

trait ValDefApi extends Universe.ValOrDefDefApi

abstract class ValDefExtractor extends AnyRef

An extractor class to create and pattern match with syntax ValDef(mods, name, tpt, rhs). This AST node corresponds to any of the following Scala code:

mods val name: tpt = rhs

mods var name: tpt = rhs

mods name: tpt = rhs // in signatures of function and method definitions

self: Bar => // self-types

If the type of a value is not specified explicitly (i.e. is meant to be inferred), this is expressed by having tpt set to TypeTree() (but not to an EmptyTree!).

abstract type ValOrDefDef >: Null <: Universe.ValOrDefDefApi with Universe.MemberDef

trait ValOrDefDefApi extends Universe.MemberDefApi

type ModifiersCreator = Universe.ModifiersExtractor

Annotations
@deprecated
Deprecated

(Since version 2.11.0) use ModifiersExtractor instead

Abstract Value Members

abstract val Alternative: Universe.AlternativeExtractor

abstract val Annotated: Universe.AnnotatedExtractor

abstract val AppliedTypeTree: Universe.AppliedTypeTreeExtractor

abstract val Apply: Universe.ApplyExtractor

abstract val Assign: Universe.AssignExtractor

abstract val AssignOrNamedArg: Universe.AssignOrNamedArgExtractor

abstract val Bind: Universe.BindExtractor

abstract val Block: Universe.BlockExtractor

abstract val CaseDef: Universe.CaseDefExtractor

abstract val ClassDef: Universe.ClassDefExtractor

abstract val CompoundTypeTree: Universe.CompoundTypeTreeExtractor

abstract val DefDef: Universe.DefDefExtractor

abstract val EmptyTree: Universe.Tree

abstract val ExistentialTypeTree: Universe.ExistentialTypeTreeExtractor

abstract val Function: Universe.FunctionExtractor

abstract def Ident(sym: Universe.Symbol): Universe.Ident

abstract val Ident: Universe.IdentExtractor

abstract val If: Universe.IfExtractor

abstract val Import: Universe.ImportExtractor

abstract val ImportSelector: Universe.ImportSelectorExtractor

abstract val LabelDef: Universe.LabelDefExtractor

abstract val Literal: Universe.LiteralExtractor

abstract val Match: Universe.MatchExtractor

abstract val Modifiers: Universe.ModifiersExtractor

abstract val ModuleDef: Universe.ModuleDefExtractor

abstract val New: Universe.NewExtractor

abstract val PackageDef: Universe.PackageDefExtractor

abstract val RefTree: Universe.RefTreeExtractor

abstract val Return: Universe.ReturnExtractor

abstract def Select(qualifier: Universe.Tree, sym: Universe.Symbol): Universe.Select

abstract val Select: Universe.SelectExtractor

abstract val SelectFromTypeTree: Universe.SelectFromTypeTreeExtractor

abstract val SingletonTypeTree: Universe.SingletonTypeTreeExtractor

abstract val Star: Universe.StarExtractor

abstract val Super: Universe.SuperExtractor

abstract val Template: Universe.TemplateExtractor

abstract def This(sym: Universe.Symbol): Universe.Tree

abstract val This: Universe.ThisExtractor

abstract val Throw: Universe.ThrowExtractor

abstract val Try: Universe.TryExtractor

abstract val TypeApply: Universe.TypeApplyExtractor

abstract val TypeBoundsTree: Universe.TypeBoundsTreeExtractor

abstract val TypeDef: Universe.TypeDefExtractor

abstract def TypeTree(tp: Universe.Type): Universe.TypeTree

abstract val TypeTree: Universe.TypeTreeExtractor

abstract val Typed: Universe.TypedExtractor

abstract val UnApply: Universe.UnApplyExtractor

abstract val ValDef: Universe.ValDefExtractor

abstract def newLazyTreeCopier: Universe.TreeCopier

abstract def newStrictTreeCopier: Universe.TreeCopier

abstract val noSelfType: Universe.ValDef

abstract val pendingSuperCall: Universe.Apply

abstract def treeToString(tree: Universe.Tree): String

Obtains string representation of a tree

Attributes
protected

abstract def Apply(sym: Universe.Symbol, args: Universe.Tree*): Universe.Tree

A factory method for Apply nodes.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use q"$sym(..$args)" instead

abstract def ApplyConstructor(tpt: Universe.Tree, args: List[Universe.Tree]): Universe.Tree

0-1 argument list new, based on a type tree.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use q"new $tpt(..$args)" instead

abstract def Bind(sym: Universe.Symbol, body: Universe.Tree): Universe.Bind

A factory method for Bind nodes.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use the canonical Bind constructor to create a bind and then initialize its symbol manually

abstract def Block(stats: Universe.Tree*): Universe.Block

A factory method for Block nodes. Flattens directly nested blocks.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use q"{..$stats}" instead. Flatten directly nested blocks manually if needed

abstract def CaseDef(pat: Universe.Tree, body: Universe.Tree): Universe.CaseDef

A factory method for CaseDef nodes.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use cq"$pat => $body" instead

abstract def Ident(name: String): Universe.Ident

A factory method for Ident nodes.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use Ident(TermName(name)) instead

abstract def New(sym: Universe.Symbol, args: Universe.Tree*): Universe.Tree

0-1 argument list new, based on a symbol.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use q"new ${sym.toType}(..$args)" instead

abstract def New(tpe: Universe.Type, args: Universe.Tree*): Universe.Tree

0-1 argument list new, based on a type.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use q"new $tpe(..$args)" instead

abstract def New(tpt: Universe.Tree, argss: List[List[Universe.Tree]]): Universe.Tree

Factory method for object creation new tpt(args_1)...(args_n) A New(t, as) is expanded to: (new t).<init>(as)

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use q"new $tpt(...$argss)" instead

abstract def Select(qualifier: Universe.Tree, name: String): Universe.Select

A factory method for Select nodes. The string name argument is assumed to represent a TermName.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use Select(tree, TermName(name)) instead

abstract def Super(sym: Universe.Symbol, mix: Universe.TypeName): Universe.Tree

A factory method for Super nodes.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use q"$sym.super[$mix].x".qualifier instead

abstract def Throw(tpe: Universe.Type, args: Universe.Tree*): Universe.Throw

A factory method for Throw nodes.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) use q"throw new $tpe(..$args)" instead

abstract def Try(body: Universe.Tree, cases: (Universe.Tree, Universe.Tree)*): Universe.Try

A factory method for Try nodes.

Annotations
@deprecated
Deprecated

(Since version 2.10.1) convert cases into casedefs and use q"try $body catch { case ..$newcases }" instead

abstract val emptyValDef: Universe.ValDef

Annotations
@deprecated
Deprecated

(Since version 2.11.0) use noSelfType instead

Concrete Value Members

final def !=(arg0: Any): Boolean

Definition Classes
AnyRef → Any

final def ##(): Int

Definition Classes
AnyRef → Any

def +(other: String): String

Implicit
This member is added by an implicit conversion from Trees to any2stringadd[Trees] performed by method any2stringadd in scala.Predef.
Definition Classes
any2stringadd

def ->[B](y: B): (Trees, B)

Implicit
This member is added by an implicit conversion from Trees to ArrowAssoc[Trees] performed by method ArrowAssoc in scala.Predef.
Definition Classes
ArrowAssoc
Annotations
@inline()

final def ==(arg0: Any): Boolean

Definition Classes
AnyRef → Any

def Modifiers(flags: Universe.FlagSet): Universe.Modifiers

def Modifiers(flags: Universe.FlagSet, privateWithin: Universe.Name): Universe.Modifiers

lazy val NoMods: Universe.Modifiers

final def asInstanceOf[T0]: T0

Definition Classes
Any

def clone(): AnyRef

Attributes
protected[lang]
Definition Classes
AnyRef
Annotations
@throws( ... ) @native()

def ensuring(cond: (Trees) ⇒ Boolean, msg: ⇒ Any): Trees

Implicit
This member is added by an implicit conversion from Trees to Ensuring[Trees] performed by method Ensuring in scala.Predef.
Definition Classes
Ensuring

def ensuring(cond: (Trees) ⇒ Boolean): Trees

Implicit
This member is added by an implicit conversion from Trees to Ensuring[Trees] performed by method Ensuring in scala.Predef.
Definition Classes
Ensuring

def ensuring(cond: Boolean, msg: ⇒ Any): Trees

Implicit
This member is added by an implicit conversion from Trees to Ensuring[Trees] performed by method Ensuring in scala.Predef.
Definition Classes
Ensuring

def ensuring(cond: Boolean): Trees

Implicit
This member is added by an implicit conversion from Trees to Ensuring[Trees] performed by method Ensuring in scala.Predef.
Definition Classes
Ensuring

final def eq(arg0: AnyRef): Boolean

Definition Classes
AnyRef

def equals(arg0: Any): Boolean

Definition Classes
AnyRef → Any

def finalize(): Unit

Attributes
protected[lang]
Definition Classes
AnyRef
Annotations
@throws( classOf[java.lang.Throwable] )

def formatted(fmtstr: String): String

Implicit
This member is added by an implicit conversion from Trees to StringFormat[Trees] performed by method StringFormat in scala.Predef.
Definition Classes
StringFormat
Annotations
@inline()

final def getClass(): Class[_]

Definition Classes
AnyRef → Any
Annotations
@native()

def hashCode(): Int

Definition Classes
AnyRef → Any
Annotations
@native()

final def isInstanceOf[T0]: Boolean

Definition Classes
Any

def itransform(transformer: Universe.Transformer, tree: Universe.Tree): Universe.Tree

Delegates the transformation strategy to scala.reflect.internal.Trees, because pattern matching on abstract types we have here degrades performance.

Attributes
protected

def itraverse(traverser: Universe.Traverser, tree: Universe.Tree): Unit

Delegates the traversal strategy to scala.reflect.internal.Trees, because pattern matching on abstract types we have here degrades performance.

Attributes
protected

final def ne(arg0: AnyRef): Boolean

Definition Classes
AnyRef

final def notify(): Unit

Definition Classes
AnyRef
Annotations
@native()

final def notifyAll(): Unit

Definition Classes
AnyRef
Annotations
@native()

final def synchronized[T0](arg0: ⇒ T0): T0

Definition Classes
AnyRef

def toString(): String

Definition Classes
AnyRef → Any

val treeCopy: Universe.TreeCopier

final def wait(): Unit

Definition Classes
AnyRef
Annotations
@throws( ... )

final def wait(arg0: Long, arg1: Int): Unit

Definition Classes
AnyRef
Annotations
@throws( ... )

final def wait(arg0: Long): Unit

Definition Classes
AnyRef
Annotations
@throws( ... ) @native()

def xtransform(transformer: Universe.Transformer, tree: Universe.Tree): Universe.Tree

Provides an extension hook for the transformation strategy. Future-proofs against new node types.

Attributes
protected

def xtraverse(traverser: Universe.Traverser, tree: Universe.Tree): Unit

Provides an extension hook for the traversal strategy. Future-proofs against new node types.

Attributes
protected

def [B](y: B): (Trees, B)

Implicit
This member is added by an implicit conversion from Trees to ArrowAssoc[Trees] performed by method ArrowAssoc in scala.Predef.
Definition Classes
ArrowAssoc

© 2002-2019 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://www.scala-lang.org/api/2.12.9/scala-reflect/scala/reflect/api/Trees.html