abstract class Tree [ -T ]
extends Positioned with Product with Container with Showable with Cloneable

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 is null (throws an exception)
  • So when creating a typed tree with withType we can re-use the existing tree transparently, assigning its tpe field, provided it was null 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

Tree ( )

Members

[+] type ThisTree = Nothing <: [T >: dotty.tools.dotc.ast.Trees.Untyped] => dotty.tools.dotc.ast.Trees.Tree[T] (not handled)

The type constructor at the root of the tree

The type constructor at the root of the tree

[+] private var myTpe : T
[+] private var myUniqueId : Int

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

[+] override def clone : Tree [ T ]
[+] def denot ( implicit ctx: Context ) : Denotation

The denotation referred tno by this tree. Defined for DenotingTrees and ProxyTrees, NoDenotation for other kinds of trees

The denotation referred tno by this tree. Defined for DenotingTrees and ProxyTrees, NoDenotation for other kinds of trees

[+] override def equals ( that: Any ) : Boolean
[+] def foreachInThicket ( op: Tree [ T ] => Unit ) : Unit

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.

[+] final def hasType : Boolean

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).

[+] override def hashCode ( ) : Int
[+] def isDef : Boolean

Does this tree define a new symbol that is not defined elsewhere?

Does this tree define a new symbol that is not defined elsewhere?

[+] def isEmpty : Boolean

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?

[+] def isPattern : Boolean

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?

[+] def isTerm : Boolean

Does this tree represent a term?

Does this tree represent a term?

[+] def isType : Boolean

Does this tree represent a type?

Does this tree represent a type?

[+] private def myUniqueId_= ( x$1: Int ) : Unit

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

[+] private def nxId : Int
[+] def orElse ( that: => Tree [ U ] ) : Tree [ U ]

if this tree is the empty tree, the alternative, else this tree

if this tree is the empty tree, the alternative, else this tree

[+] def overwriteType ( tpe: T ) : Unit

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.

[+] final def symbol ( implicit ctx: Context ) : Symbol

Shorthand for denot.symbol.

Shorthand for denot.symbol.

[+] def toList : List [ Tree [ T ] ]

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.

[+] override def toText ( printer: Printer ) : Text

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.

[+] def tpe : T

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)

[+] def treeSize : Int

The number of nodes in this tree

The number of nodes in this tree

[+] final def typeOpt : Type
[+] def uniqueId : Int
[+] def withType ( tpe: Type ) ( implicit ctx: Context ) : ThisTree [ Type ]

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)

[+] def withTypeUnchecked ( tpe: Type ) : ThisTree [ Type ]