Trees take a parameter indicating what the type of their
is. Two choices:
Untyped trees have type
Tree typing uses a copy-on-write implementation:
- You can never observe a
null(throws an exception)
- So when creating a typed tree with
withTypewe can re-use the existing tree transparently, assigning its
tpefield, provided it was
- It is impossible to embed untyped trees in typed ones.
- Typed trees can be embedded in untyped ones provided they are rooted in a TypedSplice node.
- Type checking an untyped tree should remove all embedded
The type constructor at the root of the tree
Check that typed trees don't refer to untyped ones, except if - the parent tree is an import, or - the child tree is an identifier, or - errors were reported
The denotation referred to by this tree.
ProxyTrees, NoDenotation for other
kinds of trees
If this is a thicket, perform
op on each of its trees
op ion tree itself.
Does the tree have its type field set? Note: this operation is not referentially transparent, because it can observe the withType modifications. Should be used only in special circumstances (we need it for printing trees with optional type info).
Does this tree define a new symbol that is not defined elsewhere?
Is this tree either the empty tree or the empty ValDef or an empty type ident?
Is this a legal part of a pattern which is not at the same time a term?
Does this tree represent a term?
Does this tree represent a type?
if this tree is the empty tree, the alternative, else this tree
Destructively set the type of the tree. This should be called only when it is known that it is safe under sharing to do so. One use-case is in the withType method below which implements copy-on-write. Another use-case is in method interpolateAndAdapt in Typer, where we overwrite with a simplified version of the type itself.
This tree, widened to
Positioned. Used to make clear we only need the
position, typically for error reporting.
Convert tree to a list. Gives a singleton list, except for thickets which return their element trees.
The text representation of this showable element. This normally dispatches to a pattern matching method in Printers.
The type of the tree. In case of an untyped tree, an UnAssignedTypeException is thrown. (Overridden by empty trees)
The number of nodes in this tree
Return a typed tree that's isomorphic to this tree, but has given type. (Overridden by empty trees)