Trees take a parameter indicating what the type of their tpe
field
is. Two choices: Type
or Untyped
.
Untyped trees have type Tree[Untyped]
.
Tree typing uses a copy-on-write implementation:
- You can never observe a
tpe
which isnull
(throws an exception) - So when creating a typed tree with
withType
we can re-use the existing tree transparently, assigning itstpe
field, provided it wasnull
before. - 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
TypedSplice
nodes.
Constructors
Members
The type constructor at the root of the tree
The type constructor at the root of the tree
A unique identifier for this tree. Used for debugging, and potentially tracking presentation compiler interactions
A unique identifier for this tree. Used for debugging, and potentially tracking presentation compiler interactions
The denotation referred tno by this tree.
Defined for DenotingTree
s and ProxyTree
s, NoDenotation for other
kinds of trees
The denotation referred tno by this tree.
Defined for DenotingTree
s and ProxyTree
s, NoDenotation for other
kinds of trees
If this is a thicket, perform op
on each of its trees
otherwise, perform op
ion tree itself.
If this is a thicket, perform op
on each of its trees
otherwise, perform 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...
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?
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 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?
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 term?
Does this tree represent a type?
Does this tree represent a type?
A unique identifier for this tree. Used for debugging, and potentially tracking presentation compiler interactions
A unique identifier for this tree. Used for debugging, and potentially tracking presentation compiler interactions
if this tree is the empty tree, the alternative, else this tree
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 with...
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.
Shorthand for denot.symbol
.
Shorthand for denot.symbol
.
Convert tree to a list. Gives a singleton list, except for thickets which return their element trees.
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 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 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
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)
Return a typed tree that's isomorphic to this tree, but has given type. (Overridden by empty trees)