Dotty Documentation

0.15.0-bin-SNAPSHOT

class PCPCheckAndHeal

Checks that the Phase Consistency Principle (PCP) holds and heals types.

Type healing consists in transforming a phase inconsistent type T into a splice of implicitly[Type[T]].

[-] Constructors

PCPCheckAndHeal ( ictx: Context )

[-] Members

[+] @constructorOnly private val ictx : Context
[+] protected def checkLevel ( tree: Tree ) ( implicit ctx: Context ) : Tree

If tree refers to a locally defined symbol (either directly, or in a pickled type), check that its staging level matches the current level. References to types that are phase-incorrect can still be healed as follows:

If T is a reference to a type at the wrong level, try to heal it by replacing it with ${implicitly[quoted.Type[T]]}.

[+] private def checkSymLevel ( sym: Symbol , tp: Type , pos: SourcePosition ) ( implicit ctx: Context ) : Option [ Tree ]

Check reference to sym for phase consistency, where tp is the underlying type by which we refer to sym. If it is an inconsistent type try construct a healed type for it.

[+] private def checkType ( pos: SourcePosition ) ( implicit ctx: Context ) : TypeMap

Check and heal all named types and this-types in a given type for phase consistency.

[+] private def levelOK ( sym: Symbol ) ( implicit ctx: Context ) : Boolean

Does the level of sym match the current level? An exception is made for inline vals in macros. These are also OK if their level is one higher than the current level, because on execution such values are constant expression trees and we can pull out the constant from the tree.

[+] override def transform ( tree: Tree ) ( implicit ctx: Context ) : Tree
[+] protected override def transformQuotation ( body: Tree , quote: Tree ) ( implicit ctx: Context ) : Tree

Transform quoted trees while maintaining phase correctness

[+] protected def transformSplice ( body: Tree , splice: Tree ) ( implicit ctx: Context ) : Tree

Transform splice - If inside a quote, transform the contents of the splice. - If inside inlined code, expand the macro code. - If inside of a macro definition, check the validity of the macro.

[+] protected def tryHeal ( sym: Symbol , tp: Type , pos: SourcePosition ) ( implicit ctx: Context ) : Option [ Tree ]

Try to heal phase-inconsistent reference to type T using a local type definition.