CrossStageSafety

dotty.tools.dotc.staging.CrossStageSafety

Checks that staging level consistency holds and heals staged types.

Local term references are level consistent if and only if they are used at the same level as their definition.

Local type references can be used at the level of their definition or lower. If used used at a higher level, it will be healed if possible, otherwise it is inconsistent.

Healing a type consists in replacing locally defined types defined at staging level 0 and used in higher levels. For each type local T that is defined at level 0 and used in a quote, we summon a tag t: Type[T]. This t tag must be defined at level 0. The tags will be listed in the tags of the level 0 quote ('<t>{ ... }) and each reference to T will be replaced by t.Underlying in the body of the quote.

We delay the healing of types in quotes at level 1 or higher until those quotes reach level 0. At this point more types will be statically known and fewer types will need to be healed. This also keeps the nested quotes in their original form, we do not want macro users to see any artifacts of this phase in quoted expressions they might inspect.

Type heal example:

'{ val x: List[T] = ListT '{ .. T .. } () }

is transformed to

' { // where t is a given term of type Type[T] val x: List[t.Underlying] = List t.Underlying; '{ .. t.Underlying .. } () }

Attributes

Graph
Supertypes
class TreeMap
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def transform(tree: Tree)(using Context): Tree

Attributes

Definition Classes

Inherited methods

def transform(trees: List[Tree])(using Context): List[Tree]

Attributes

Inherited from:
TreeMap
override def transformBlock(blk: Block)(using Context): Block

Attributes

Definition Classes
Inherited from:
TreeMapWithPreciseStatContexts

Attributes

Inherited from:
TreeMap

Attributes

Inherited from:
TreeMap
def transformSelf(vd: ValDef)(using Context): ValDef

Attributes

Inherited from:
TreeMapWithImplicits
final override def transformStats(trees: List[Tree], exprOwner: Symbol)(using Context): List[Tree]

Attributes

Definition Classes
Inherited from:
TreeMapWithPreciseStatContexts
def transformStats[T](trees: List[Tree], exprOwner: Symbol, wrapResult: List[Tree] => Context ?=> T)(using Context): T

Attributes

Inherited from:
TreeMapWithPreciseStatContexts
def transformSub[Tr <: Tree](trees: List[Tr])(using Context): List[Tr]

Attributes

Inherited from:
TreeMap
def transformSub[Tr <: Tree](tree: Tr)(using Context): Tr

Attributes

Inherited from:
TreeMap

Inherited fields

Attributes

Inherited from:
TreeMap