tpd
Some creators for typed trees
Type members
Classlikes
Map Inlined nodes, NamedArgs, Blocks with no statements and local references to underlying arguments. Also drops Inline and Block with no statements.
Map Inlined nodes, NamedArgs, Blocks with no statements and local references to underlying arguments. Also drops Inline and Block with no statements.
An extractor that pulls out type arguments
An extractor that pulls out type arguments
A trait for loaders that compute trees. Currently implemented just by DottyUnpickler.
A trait for loaders that compute trees. Currently implemented just by DottyUnpickler.
Inherited 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]
.
- Inherited from:
- TypedTreeInfo
Fold f
over all tree nodes, in depth-first, prefix order
Fold f
over all tree nodes, in depth-first, prefix order
- Inherited from:
- Instance
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
.
- Inherited from:
- Instance
Extractors for type splices
Extractors for type splices
- Inherited from:
- TypedTreeInfo
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.
- Inherited from:
- Instance
An extractor for closures, either contained in a block or standalone.
An extractor for closures, either contained in a block or standalone.
- Inherited from:
- TypedTreeInfo
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.
- Inherited from:
- TypedTreeInfo
Inherited types
Value members
Concrete methods
An anonymous class
An anonymous class
new parents { forwarders }
where forwarders
contains forwarders for all functions in fns
.
- Value parameters:
- fns
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 infns
.- parents
a non-empty list of class types
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).
A closure whose anonymous function has the given method type
A closure whose anonymous function has the given method type
An object def
An object def
object obs extends parents { decls }
gets expanded to
(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 given constructor constr
of C
A tree that corresponds to Predef.classOf[$tp]
in source
A tree that corresponds to Predef.classOf[$tp]
in source
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
Recover identifier prefix (e.g. this) if it exists
Recover identifier prefix (e.g. this) if it exists
All enclosing calls that are currently inlined, from innermost to outermost.
All enclosing calls that are currently inlined, from innermost to outermost.
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
.
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.
- Returns:
All the symbols that would be imported with
expr.name
.
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.
- Returns:
The symbols imported.
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.
- Definition Classes
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)
The owner to be used in a local context when traversin a tree
The owner to be used in a local context when traversin a 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:
- tpe
the type of the elements of the resulting list.
- trees
the elements the list represented by the resulting tree should contain.
Creates the nested pairs type tree repesentation of the type trees in ts
Creates the nested pairs type tree repesentation of the type trees in ts
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.
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.
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
A tree representing the same reference as the given type
A tree representing the same reference as the given type
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.
Join stats
in front of expr
creating a new block if necessary
Join stats
in front of expr
creating a new block if necessary
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
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
Creates the tuple type tree repesentation of the type trees in ts
Creates the tuple type tree repesentation of the type trees in ts
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
.
Inherited 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
- Inherited from:
- TypedTreeInfo
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
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
- Inherited from:
- Instance
Does this CaseDef catch everything of a certain Type?
Does this CaseDef catch everything of a certain Type?
- Inherited from:
- TreeInfo
If tree is a closure, its body, otherwise tree itself
If tree is a closure, its body, otherwise tree itself
- Inherited from:
- TypedTreeInfo
(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.
- Inherited from:
- TypedTreeInfo
Decompose a template body into parameters and other statements
Decompose a template body into parameters and other statements
- Inherited from:
- TypedTreeInfo
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.
- Inherited from:
- TypedTreeInfo
If tree
is a DefTree, the symbol defined by it, otherwise NoSymbol
If tree
is a DefTree, the symbol defined by it, otherwise NoSymbol
- Inherited from:
- TypedTreeInfo
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.
- Inherited from:
- TypedTreeInfo
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.
- Inherited from:
- TypedTreeInfo
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
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
- Inherited from:
- TypedTreeInfo
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 or type-test pattern?
Is this pattern node a catch-all or type-test pattern?
- Inherited from:
- TypedTreeInfo
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 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.
- 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*?
- Inherited from:
- TreeInfo
Is tree a this
node which belongs to enclClass
?
Is tree a this
node which belongs to enclClass
?
- 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?
- 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?
- Inherited from:
- TypedTreeInfo
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 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?
- Inherited from:
- TypedTreeInfo
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 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.
- 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.
- Inherited from:
- TreeInfo
The symbols defined locally in a statement list
The symbols defined locally in a statement list
- Inherited from:
- TypedTreeInfo
Is symbol potentially a getter of a mutable variable?
Is symbol potentially a getter of a mutable variable?
- Inherited from:
- TypedTreeInfo
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
The variables defined by a pattern, in reverse order of their appearance.
The variables defined by a pattern, in reverse order of their appearance.
- Inherited from:
- TypedTreeInfo
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.
- Inherited from:
- TypedTreeInfo
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
- Inherited from:
- TypedTreeInfo
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
- Inherited from:
- TypedTreeInfo
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)
- Inherited from:
- TypedTreeInfo
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
- Inherited from:
- TypedTreeInfo
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
Strips layers of .asInstanceOf[T]
/ _.$asInstanceOf[T]()
from an expression
Strips layers of .asInstanceOf[T]
/ _.$asInstanceOf[T]()
from an expression
- Inherited from:
- TypedTreeInfo
The term arguments of a possibly curried call
The term arguments of a possibly curried call
- Inherited from:
- TypedTreeInfo
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 from:
- TypedTreeInfo
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.
- Inherited from:
- TypedTreeInfo
The type arguments of a possibly curried call
The type arguments of a possibly curried call
- Inherited from:
- TypedTreeInfo
The underlying pattern ignoring any bindings
The underlying pattern ignoring any bindings
- Inherited from:
- TreeInfo
Concrete fields
Inherited fields
Extensions
Extensions
A map that expands to a recursive function. It's equivalent to
A map that expands to a recursive function. It's equivalent to
flatten(trees.mapConserve(op))
and falls back to it after MaxRecursionLimit
recursions.
Before that it uses a simpler method that uses stackspace
instead of heap.
Note op
is duplicated in the generated code, so it should be
kept small.
Inherited 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
- Inherited from:
- TypedTreeInfo
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
- Inherited from:
- TypedTreeInfo