TypedTreeInfo
Type members
Classlikes
Extractor for not-null assertions.
A not-null assertion for reference x
has the form x.$asInstanceOf$[x.type & T]
.
Extractor for not-null assertions.
A not-null assertion for reference x
has the form x.$asInstanceOf$[x.type & T]
.
An extractor for closures, either contained in a block or standalone.
An extractor for closures, either contained in a block or standalone.
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.
Value members
Concrete methods
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
If tree is a closure, its body, otherwise tree itself
If tree is a closure, its body, otherwise tree itself
(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.
Decompose a template body into parameters and other statements
Decompose a template body into parameters and other statements
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.
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.
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.
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.
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
Is this pattern node a catch-all or type-test pattern?
Is this pattern node a catch-all or type-test pattern?
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.
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?
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 symbol potentially a getter of a mutable variable?
Is symbol potentially a getter of a mutable variable?
The variables defined by a pattern, in reverse order of their appearance.
The variables defined by a pattern, in reverse order of their appearance.
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.
The purity level of this reference.
The purity level of this reference.
- Returns:
PurePath if reference is (nonlazy and stable) or to a parameterized function or its type is a constant type IdempotentPath if reference is lazy and stable Impure otherwise
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
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)
The purity level of this statement.
The purity level of this statement.
- Returns:
Pure if statement has no side effects Idempotent if running the statement a second time has no side effects Impure otherwise
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.
Inherited methods
All term arguments of an application in a single flattened list
All term arguments of an application in a single flattened list
- Inherited from:
- TreeInfo
All type and value parameter symbols of this DefDef
All type and value parameter symbols of this DefDef
- Inherited from:
- TreeInfo
Does this CaseDef catch everything of a certain Type?
Does this CaseDef catch everything of a certain Type?
- Inherited from:
- TreeInfo
The first constructor definition in stats
The first constructor definition in stats
- Inherited from:
- TreeInfo
Checks whether predicate p
is true for all result parts of this expression,
where we zoom into Ifs, Matches, and Blocks.
Checks whether predicate p
is true for all result parts of this expression,
where we zoom into Ifs, Matches, and Blocks.
- Inherited from:
- TreeInfo
Does this list contain a named argument tree?
Does this list contain a named argument tree?
- Inherited from:
- TreeInfo
Is tree a backquoted identifier or definition
Is tree a backquoted identifier or definition
- 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?
- Inherited from:
- TreeInfo
Is tpt a vararg type of the form T* or => T*?
Is tpt a vararg type of the form T* or => T*?
- Inherited from:
- TreeInfo
Is tree a self constructor call this(...)? I.e. a call to a constructor of the same object?
Is tree a self constructor call this(...)? I.e. a call to a constructor of the same object?
- Inherited from:
- TreeInfo
Is this pattern node a synthetic catch-all case, added during PartialFuction synthesis before we know whether the user provided cases are exhaustive.
Is this pattern node a synthetic catch-all case, added during PartialFuction synthesis before we know whether the user provided cases are exhaustive.
- Inherited from:
- TreeInfo
Is this parameter list a using clause?
Is this parameter list a using clause?
- Inherited from:
- TreeInfo
Is the argument a wildcard argument of the form _
or x @ _
?
Is the argument a wildcard argument of the form _
or x @ _
?
- Inherited from:
- TreeInfo
Is this argument node of the form
Is this argument node of the form
- 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
- Inherited from:
- TreeInfo
If path
looks like a language import, Some(name)
where name
is experimental
if that sub-module is imported, and the empty
term name otherwise.
If path
looks like a language import, Some(name)
where name
is experimental
if that sub-module is imported, and the empty
term name otherwise.
- Inherited from:
- TreeInfo
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.
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.
- Inherited from:
- TreeInfo
The number of arguments in an application
The number of arguments in an application
- Inherited from:
- TreeInfo
The largest subset of {NoInits, PureInterface} that a trait or class with these parents can have as flags.
The largest subset of {NoInits, PureInterface} that a trait or class with these parents can have as flags.
- Inherited from:
- TreeInfo
If this is an application, its function part, stripping all Apply nodes (but leaving TypeApply nodes in). Otherwise the tree itself.
If this is an application, its function part, stripping all Apply nodes (but leaving TypeApply nodes in). Otherwise the tree itself.
- Inherited from:
- TreeInfo
If this is a block, its expression part
If this is a block, its expression part
- Inherited from:
- TreeInfo
The underlying pattern ignoring any bindings
The underlying pattern ignoring any bindings
- Inherited from:
- TreeInfo
Inherited fields
Extensions
Extensions
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