Fold f
over all tree nodes, in depth-first, prefix order
Fold f
over all tree nodes, in depth-first, prefix order
A traverser that passes the enclosing class or method as an argument to the traverse method.
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.
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
.
A class for copying trees.
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.
An anonymous class
An anonymous class
new parents { forwarders }
where forwarders
contains forwarders for all functions in fns
.
a non-empty list of class types
a non-empty of functions for which forwarders should be defined in the class.
The class has the same owner as the first function in fns
.
Its position is the union of all functions in fns
.
A pattern corresponding to sym: tpe
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).
An extractor that pulls out type arguments
An object def
An object def
object obs extends parents { decls }
gets expanded to
<module> val obj = new obj$ <module> 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.)
new C(args), calling given constructor constr
of C
new C(args), calling the primary constructor of C
A _' with given type
The (last) list of arguments of an application
The (last) list of arguments of an application
Does this CaseDef catch everything of a certain Type?
Does this CaseDef catch everything of a certain Type?
Does this CaseDef catch Throwable?
Does this CaseDef catch Throwable?
An extractor for closures, either contained in a block or standalone.
An extractor for closures, either contained in a block or standalone.
If tree is a closure, its body, otherwise tree itself
If tree is a closure, its body, otherwise tree itself
A tree that represents the class of the erasure of type tp
.
If tree
is a constant expression, its value as a Literal,
or tree
itself otherwise.
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 implemented inline
. Then we can demand
purity of the prefix unless the selection goes to an 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
Decompose a call fn[targs](vargs_1)...(vargs_n) into its constituents (where targs, vargss may be empty)
Decompose a call fn[targs](vargs_1)...(vargs_n) into its constituents (where targs, vargss may be empty)
The largest subset of {NoInits, PureInterface} that a trait enclosing this statement can have as flags.
The largest subset of {NoInits, PureInterface} that a trait enclosing this statement can have as flags. Does tree contain an initialization part when seen as a member of a class or trait?
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.
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.
If tree
is a DefTree, the symbol defined by it, otherwise NoSymbol
If tree
is a DefTree, the symbol defined by it, otherwise NoSymbol
The statement sequence that contains a definition of sym
, or Nil
if none was found.
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.
All enclosing calls that are currently inlined, from innermost to outermost
The first constructor definition in stats
The first constructor definition in stats
The arguments to the first constructor in stats
.
The arguments to the first constructor in stats
.
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.
Does this list contain a named argument tree?
Does this list contain a named argument tree?
A context derived form ctx
that records call
as innermost enclosing
call for which the inlined version is currently processed.
Is this pattern node a catch-all or type-test pattern?
Is this pattern node a catch-all or type-test pattern?
Is this pattern node a catch-all (wildcard or variable) pattern?
Is this pattern node a catch-all (wildcard or variable) pattern?
Is this case guarded?
Is this case guarded?
Is name a left-associative operator?
Is name a left-associative operator?
Is tpt a vararg type of the form T* or => T*?
Is tpt a vararg type of the form T* or => T*?
Is tree a this
node which belongs to enclClass
?
Is tree a this
node which belongs to enclClass
?
Is tree a self constructor call this(...)? I.e.
Is tree a self constructor call this(...)? I.e. a call to a constructor of the same object?
Is tree a super constructor call?
Is tree a super constructor call?
Is this pattern node a synthetic catch-all case, added during PartialFuction synthesis before we know whether the user provided cases are exhaustive.
Is this pattern node a synthetic catch-all case, added during PartialFuction synthesis before we know whether the user provided cases are exhaustive.
Is tree a variable pattern?
Is tree a variable pattern?
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?
Is the argument a wildcard argument of the form _
or x @ _
?
Is the argument a wildcard argument of the form _
or x @ _
?
Is this argument node of the form <expr> : _* ?
Is this argument node of the form <expr> : _* ?
Does this argument list end with an argument of the form <expr> : _* ?
Does this argument list end with an argument of the form <expr> : _* ?
The symbols defined locally in a statement list
The symbols defined locally in a statement list
can this type be a type pattern?
can this type be a type pattern?
Is symbol potentially a getter of a mutable variable?
Is symbol potentially a getter of a mutable variable?
The method part of an application node, possibly enclosed in a block with only valdefs as statements.
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. <init>(b = foo, a = bar) is transformed to { val x$1 = foo val x$2 = bar <init>(x$2, x$1) }
A tree representing a newXYZArray
operation of the right
kind for the given element type in typeArg
.
A tree representing a newXYZArray
operation of the right
kind for the given element type in typeArg
. No type arguments or
length
arguments are given.
The number of arguments in an application
The number of arguments in an application
The variables defined by a pattern, in reverse order of their appearance.
The variables defined by a pattern, in reverse order of their appearance.
A tree representing the same reference as the given type
Join stats
in front of expr
creating a new block if necessary
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
The source file where the symbol of the @inline
method referred to by call
is defined
If this is an application, its function part, stripping all Apply nodes (but leaving TypeApply nodes in).
If this is an application, its function part, stripping all Apply nodes (but leaving TypeApply nodes in). Otherwise the tree itself.
Strips layers of .asInstanceOf[T]
/ _.$asInstanceOf[T]()
from an expression
Strips layers of .asInstanceOf[T]
/ _.$asInstanceOf[T]()
from an expression
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.
The underlying pattern ignoring any bindings
The underlying pattern ignoring any bindings
Throws an UnsupportedOperationException
with the given method name.
Throws an UnsupportedOperationException
with the given method name.
Some creators for typed trees