Trees

object Trees
class Object
trait Matchable
class Any

Type members

Classlikes

case
class Alternative(trees: List[Tree])(span: Span) extends Tree

tree_1 | ... | tree_n

tree_1 | ... | tree_n

case
class Apply(fun: Tree, args: List[Tree])(span: Span) extends Tree

fun(args)

fun(args)

case
class Assign(lhs: Tree, rhs: Tree)(span: Span) extends Tree

name = arg, outside a parameter list

name = arg, outside a parameter list

case
class Bind(name: Name, body: Tree, symbol: TermSymbol)(span: Span) extends Tree with DefTree

pattern in [[Unapply]]

pattern in [[Unapply]]

case
class Block(stats: List[Tree], expr: Tree)(span: Span) extends Tree

{ stats; expr }

{ stats; expr }

case
class CaseDef(pattern: Tree, guard: Tree, body: Tree)(span: Span) extends Tree

case pattern if guard => body; only appears as child of a Match and Try

case pattern if guard => body; only appears as child of a Match and Try

case
class ClassDef(name: TypeName, rhs: Template, symbol: ClassSymbol)(span: Span) extends TypeDef
case
class DefDef(name: TermName, paramLists: List[ParamsClause], resultTpt: TypeTree, rhs: Tree, symbol: TermSymbol)(span: Span) extends Tree with DefTree

mods def nametparams...(vparams_n): tpt = rhs

mods def nametparams...(vparams_n): tpt = rhs

trait DefTree(val symbol: Symbol)
case
object EmptyTree extends Tree
case
class Export(expr: Tree, selectors: List[ImportSelector])(span: Span) extends Tree

import expr.selectors

import expr.selectors

final
class FreeIdent(name: TermName, tpe: Type)(span: Span) extends Ident

A free identifier, that has no defining symbol.

A free identifier, that has no defining symbol.

This seems to always be a wildcard.

abstract case
class Ident(name: TermName)(span: Span) extends Tree

name

name

case
class If(cond: Tree, thenPart: Tree, elsePart: Tree)(span: Span) extends Tree

if cond then thenp else elsep

if cond then thenp else elsep

case
class Import(expr: Tree, selectors: List[ImportSelector])(span: Span) extends Tree
final
class ImportIdent(name: TermName)(span: Span) extends Ident

An identifier appearing in an import clause; it has no type.

An identifier appearing in an import clause; it has no type.

case
class ImportSelector(imported: Ident, renamed: Tree, bound: TypeTree)(span: Span) extends Tree
class InlineIf(cond: Tree, thenPart: Tree, elsePart: Tree)(span: Span) extends If
class InlineMatch(selector: Tree, cases: List[CaseDef])(span: Span) extends Match
case
class Inlined(expr: Tree, caller: TypeIdent, bindings: List[Tree])(span: Span) extends Tree

A tree representing inlined code.

A tree representing inlined code.

Value Params
bindings

Bindings for proxies to be used in the inlined code The full inlined code is equivalent to { bindings; expr }

caller

The toplevel class from which the call was inlined.

expr

The inlined tree, minus bindings.

case
class Lambda(meth: Tree, tpt: TypeTree)(span: Span) extends Tree
Value Params
meth

A reference to the method.

tpt

Not an EmptyTree only if the lambda's type is a SAMtype rather than a function type.

case
class Literal(constant: Constant)(span: Span) extends Tree
case
class Match(selector: Tree, cases: List[CaseDef])(span: Span) extends Tree

selector match { cases }

selector match { cases }

case
class NamedArg(name: Name, arg: Tree)(span: Span) extends Tree

name = arg, in a parameter list

name = arg, in a parameter list

case
class New(tpt: TypeTree)(span: Span) extends Tree

new tpt, but no constructor call

new tpt, but no constructor call

case
class PackageDef(pid: PackageSymbol, stats: List[Tree])(span: Span) extends Tree with DefTree
final
class ReferencedPackage(val fullyQualifiedName: FullyQualifiedName)(span: Span) extends Ident

reference to a package, seen as a term

reference to a package, seen as a term

Companion
object
Companion
class
case
class Return(expr: Tree, from: Tree)(span: Span) extends Tree
case
class Select(qualifier: Tree, name: TermName)(span: Span) extends Tree

qualifier.termName

qualifier.termName

class SelectIn(qualifier: Tree, name: SignedName, selectOwner: TypeRef)(span: Span) extends Select
case
class SelfDef(name: TermName, tpt: TypeTree)(span: Span) extends Tree

Self type definition name: tpt =>.

Self type definition name: tpt =>.

Companion
object
object SelfDef
Companion
class
case
class SeqLiteral(elems: List[Tree], elemtpt: TypeTree)(span: Span) extends Tree

Seq(elems)

Seq(elems)

Value Params
tpt

The element type of the sequence.

abstract
class SimpleRef(name: TermName, tpe: Type)(span: Span) extends Ident
case
class Super(qual: Tree, mix: Option[TypeIdent])(span: Span) extends Tree

C.super[mix], where qual = C.this

C.super[mix], where qual = C.this

case
class Template(constr: DefDef, parents: List[Apply | Block | TypeTree], self: SelfDef, body: List[Tree])(span: Span) extends Tree

constr extends parents { self => body }

constr extends parents { self => body }

holder for details of a Class definition

Value Params
classParent

-- the parent whose constructor is called. If the template defines a class, this is its only class parent.

parents

trait parents of the template and the class parent if the template defines a trait.

final
class TermRefTree(name: TermName, tpe: Type)(span: Span) extends SimpleRef
case
class This(qualifier: Option[TypeIdent])(span: Span) extends Tree

qual.this

qual.this

case
class Throw(expr: Tree)(span: Span) extends Tree

throw expr

throw expr

abstract
class Tree(val span: Span)
case
class Try(expr: Tree, cases: List[CaseDef], finalizer: Tree)(span: Span) extends Tree

try block catch cases finally finalizer

try block catch cases finally finalizer

case
class TypeApply(fun: Tree, args: List[TypeTree])(span: Span) extends Tree

fun[args]

fun[args]

abstract
class TypeDef(name: TypeName, val symbol: TypeSymbol)(span: Span) extends Tree with DefTree

mods class name template or mods trait name template or mods type name = rhs or mods type name >: lo <: hi, if rhs = TypeBoundsTree(lo, hi) or mods type name >: lo <: hi = rhs if rhs = TypeBoundsTree(lo, hi, alias) and opaque in mods

mods class name template or mods trait name template or mods type name = rhs or mods type name >: lo <: hi, if rhs = TypeBoundsTree(lo, hi) or mods type name >: lo <: hi = rhs if rhs = TypeBoundsTree(lo, hi, alias) and opaque in mods

case
class TypeMember(name: TypeName, rhs: TypeTree | TypeBounds, symbol: TypeMemberSymbol)(span: Span) extends TypeDef

A type member has a type tree rhs if the member is defined by the user, or typebounds if it's synthetic

A type member has a type tree rhs if the member is defined by the user, or typebounds if it's synthetic

case
class TypeParam(name: TypeName, bounds: TypeBoundsTree | TypeBounds | TypeLambdaTree, symbol: TypeParamSymbol)(span: Span) extends TypeDef

The bounds are a type tree if the method is defined by the user and bounds-only if it's synthetic

The bounds are a type tree if the method is defined by the user and bounds-only if it's synthetic

case
class Typed(expr: Tree, tpt: TypeTree)(span: Span) extends Tree

expr : tpt

expr : tpt

case
class Unapply(fun: Tree, implicits: List[Tree], patterns: List[Tree])(span: Span) extends Tree

extractor(patterns) in a pattern:

extractor(patterns) in a pattern:

Value Params
fun

is extractor.unapply (or, for backwards compatibility, extractor.unapplySeq) possibly with type parameters

implicits

Any implicit parameters passed to the unapply after the selector

patterns

The argument patterns in the pattern match. It is typed with same type as first fun argument Given a match selector sel a pattern UnApply(fun, implicits, patterns) is roughly translated as follows val result = fun(sel)(implicits) if (result.isDefined) "match patterns against result"

case
class ValDef(name: TermName, tpt: TypeTree, rhs: Tree, symbol: TermSymbol)(span: Span) extends Tree with DefTree

mods val name: tpt = rhs

mods val name: tpt = rhs

case
class While(cond: Tree, body: Tree)(span: Span) extends Tree

while (cond) { body }

while (cond) { body }

Types

type ParamsClause = Either[List[ValDef], List[TypeParam]]