PCPCheckAndHeal

dotty.tools.dotc.transform.PCPCheckAndHeal
See thePCPCheckAndHeal companion object

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

Local term references are phase 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.

Type healing consists in transforming a phase inconsistent type T into summon[Type[T]].Underlying.

As references to types do not necessarily have an associated tree it is not always possible to replace the types directly. Instead we always generate a type alias for it and place it at the start of the surrounding quote. This also avoids duplication. For example: '{ val x: List[T] = ListT () }

is transformed to

'{ type t$1 = summon[Type[T]].Underlying val x: List[t$1] = Listt$1; () }

Attributes

Companion
object
Graph
Supertypes
trait Checking
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 checkAnnotApplicable(annot: Tree, sym: Symbol)(using Context): Boolean

check that annotation annot is applicable to symbol sym

check that annotation annot is applicable to symbol sym

Attributes

Inherited from:
Checking
def checkAnnotArgs(tree: Tree)(using Context): Tree

Check arguments of compiler-defined annotations

Check arguments of compiler-defined annotations

Attributes

Inherited from:
Checking
def checkAnnotClass(tree: Tree)(using Context): Tree

Check that the class corresponding to this tree is either a Scala or Java annotation.

Check that the class corresponding to this tree is either a Scala or Java annotation.

Attributes

Returns

The original tree or an error tree in case tree isn't a valid annotation or already an error tree.

Inherited from:
Checking
def checkCanThrow(tp: Type, span: Span)(using Context): Tree

Check that there is an implicit capability to throw a checked exception if the saferExceptions feature is turned on. Return that capability is it exists, EmptyTree otherwise.

Check that there is an implicit capability to throw a checked exception if the saferExceptions feature is turned on. Return that capability is it exists, EmptyTree otherwise.

Attributes

Inherited from:
Checking
def checkCaseInheritance(parent: Symbol, caseCls: ClassSymbol, pos: SrcPos)(using Context): Unit

Check that case classes are not inherited by case classes.

Check that case classes are not inherited by case classes.

Attributes

Inherited from:
Checking
def checkCatch(pat: Tree, guard: Tree)(using Context): Unit

Check that catch can generate a good CanThrow exception

Check that catch can generate a good CanThrow exception

Attributes

Inherited from:
Checking
def checkClassType(tp: Type, pos: SrcPos, traitReq: Boolean, stablePrefixReq: Boolean)(using Context): Type

Check that tp is a class type. Also, if traitReq is true, check that tp is a trait. Also, if stablePrefixReq is true and phase is not after RefChecks, check that class prefix is stable.

Check that tp is a class type. Also, if traitReq is true, check that tp is a trait. Also, if stablePrefixReq is true and phase is not after RefChecks, check that class prefix is stable.

Attributes

Returns

tp itself if it is a class or trait ref, ObjectType if not.

Inherited from:
Checking
def checkDerivedValueClass(clazz: Symbol, stats: List[Tree])(using Context): Unit

Verify classes extending AnyVal meet the requirements

Verify classes extending AnyVal meet the requirements

Attributes

Inherited from:
Checking
def checkEnum(cdef: TypeDef, cls: Symbol, firstParent: Symbol)(using Context): Unit
  1. Check that all case classes that extend scala.reflect.Enum are enum cases
  2. Check that parameterised enum cases do not extend java.lang.Enum.
  3. Check that only a static enum base class can extend java.lang.Enum.
  4. Check that user does not implement an ordinal method in the body of an enum class.

Attributes

Inherited from:
Checking
def checkEnumCaseRefsLegal(cdef: TypeDef, enumCtx: Context)(using Context): Unit

Check that all references coming from enum cases in an enum companion object are legal.

Check that all references coming from enum cases in an enum companion object are legal.

Value parameters

cdef

the enum companion object class

enumCtx

the context immediately enclosing the corresponding enum

Attributes

Inherited from:
Checking
def checkEnumParent(cls: Symbol, firstParent: Symbol)(using Context): Unit

Check that the firstParent for an enum case derives from the declaring enum class, if not, adds it as a parent after emitting an error.

Check that the firstParent for an enum case derives from the declaring enum class, if not, adds it as a parent after emitting an error.

This check will have no effect on simple enum cases as their parents are inferred by the compiler.

Attributes

Inherited from:
Checking
def checkFeasibleParent(tp: Type, pos: SrcPos, where: => String)(using Context): Type

Check that tp is a class type and that any top-level type arguments in this type are feasible, i.e. that their lower bound conforms to their upper bound. If a type argument is infeasible, issue and error and continue with upper bound.

Check that tp is a class type and that any top-level type arguments in this type are feasible, i.e. that their lower bound conforms to their upper bound. If a type argument is infeasible, issue and error and continue with upper bound.

Attributes

Inherited from:
Checking
def checkFeature(name: TermName, description: => String, featureUseSite: Symbol, pos: SrcPos)(using Context): Unit

Issue a feature warning if feature is not enabled

Issue a feature warning if feature is not enabled

Attributes

Inherited from:
Checking
def checkFullyAppliedType(tree: Tree)(using Context): Unit

Check that user-defined (result) type is fully applied

Check that user-defined (result) type is fully applied

Attributes

Inherited from:
Checking

If sym is an old-style implicit conversion, check that implicit conversions are enabled.

If sym is an old-style implicit conversion, check that implicit conversions are enabled.

Attributes

Inherited from:
Checking
def checkImplicitConversionUseOK(tree: Tree, expected: Type)(using Context): Unit

If tree is an application of a new-style implicit conversion (using the apply method of a scala.Conversion instance), check that the expected type is a convertible formal parameter type or that implicit conversions are enabled.

If tree is an application of a new-style implicit conversion (using the apply method of a scala.Conversion instance), check that the expected type is a convertible formal parameter type or that implicit conversions are enabled.

Attributes

Inherited from:
Checking
def checkImportSelectors(qualType: Type, selectors: List[ImportSelector])(using Context): Unit

(1) Check that every named import selector refers to a type or value member of the qualifier type. (2) Check that no import selector is renamed more than once.

(1) Check that every named import selector refers to a type or value member of the qualifier type. (2) Check that no import selector is renamed more than once.

Attributes

Inherited from:
Checking
def checkInInlineContext(what: String, pos: SrcPos)(using Context): Unit

Check that we are in an inline context (inside an inline method or in inline code)

Check that we are in an inline context (inside an inline method or in inline code)

Attributes

Inherited from:
Checking
def checkIrrefutable(sel: Tree, pat: Tree, isPatDef: Boolean)(using Context): Boolean

Check that pattern pat is irrefutable for scrutinee type sel.tpe. This means sel is either marked @unchecked or sel.tpe conforms to the pattern's type. If pattern is an UnApply, also check that the extractor is irrefutable, and do the check recursively.

Check that pattern pat is irrefutable for scrutinee type sel.tpe. This means sel is either marked @unchecked or sel.tpe conforms to the pattern's type. If pattern is an UnApply, also check that the extractor is irrefutable, and do the check recursively.

Attributes

Inherited from:
Checking
def checkLegalExportPath(path: Tree, selectors: List[ImportSelector])(using Context): Unit

Check that path is a legal prefix for an export clause

Check that path is a legal prefix for an export clause

Attributes

Inherited from:
Checking
def checkLegalImportPath(path: Tree)(using Context): Unit

Check that path is a legal prefix for an import clause

Check that path is a legal prefix for an import clause

Attributes

Inherited from:
Checking
def checkMatchable(tp: Type, pos: SrcPos, pattern: Boolean)(using Context): Unit

Attributes

Inherited from:
Checking
def checkMembersOK(tp: Type, pos: SrcPos)(using Context): Type

Check that all named types that form part of this type have a denotation. Called on inferred (result) types of ValDefs and DefDefs. This could fail for types where the member was originally available as part of the self type, yet is no longer visible once the this has been replaced by some other prefix. See neg/i3083.scala

Check that all named types that form part of this type have a denotation. Called on inferred (result) types of ValDefs and DefDefs. This could fail for types where the member was originally available as part of the self type, yet is no longer visible once the this has been replaced by some other prefix. See neg/i3083.scala

Attributes

Inherited from:
Checking

Check that tree does not define a context function type

Check that tree does not define a context function type

Attributes

Inherited from:
Checking

Check that class does not declare same symbol twice

Check that class does not declare same symbol twice

Attributes

Inherited from:
Checking

Check that method parameter types do not reference their own parameter or later parameters in the same parameter section.

Check that method parameter types do not reference their own parameter or later parameters in the same parameter section.

Attributes

Inherited from:
Checking

Check that module sym does not clash with a class of the same name that is concurrently compiled in another source file.

Check that module sym does not clash with a class of the same name that is concurrently compiled in another source file.

Attributes

Inherited from:
Checking

Check that symbol's external name does not clash with symbols defined in the same scope

Check that symbol's external name does not clash with symbols defined in the same scope

Attributes

Inherited from:
Checking
def checkNonCyclic(sym: Symbol, info: TypeBounds, reportErrors: Boolean)(using Context): Type

Attributes

Inherited from:
Checking
def checkNonCyclicInherited(joint: Type, parents: List[Type], decls: Scope, pos: SrcPos)(using Context): Unit

Attributes

Inherited from:
Checking
def checkParentCall(call: Tree, caller: ClassSymbol)(using Context): Unit

Attributes

Inherited from:
Checking
def checkRealizableBounds(cls: Symbol, pos: SrcPos)(using Context): Unit

Check that all type members of tp have realizable bounds

Check that all type members of tp have realizable bounds

Attributes

Inherited from:
Checking
def checkRefsLegal(tree: Tree, badOwner: Symbol, allowed: (Name, Symbol) => Boolean, where: String)(using Context): Unit

Check that all non-synthetic references of the form <ident> or this.<ident> in tree that refer to a member of badOwner are allowed. Also check that there are no other explicit this references to badOwner.

Check that all non-synthetic references of the form <ident> or this.<ident> in tree that refer to a member of badOwner are allowed. Also check that there are no other explicit this references to badOwner.

Attributes

Inherited from:
Checking
def checkSimpleKinded(tpt: Tree)(using Context): Tree

Check that tpt does not define a higher-kinded type

Check that tpt does not define a higher-kinded type

Attributes

Inherited from:
Checking
def checkStable(tp: Type, pos: SrcPos, kind: String)(using Context): Unit

Check that type tp is stable.

Check that type tp is stable.

Attributes

Inherited from:
Checking
def checkTraitInheritance(parent: Symbol, cls: ClassSymbol, pos: SrcPos)(using Context): Unit

Given a parent parent of a class cls, if parent is a trait check that the superclass of cls derived from the superclass of parent.

Given a parent parent of a class cls, if parent is a trait check that the superclass of cls derived from the superclass of parent.

An exception is made if cls extends Any, and parent is java.io.Serializable or java.lang.Comparable. These two classes are treated by Scala as universal traits. E.g. the following is OK:

... extends Any with java.io.Serializable

The standard library relies on this idiom.

Attributes

Inherited from:
Checking
def checkValidInfix(tree: InfixOp, meth: Symbol)(using Context): Unit

Check that tree is a valid infix operation. That is, if the operator is alphanumeric, it must be declared infix.

Check that tree is a valid infix operation. That is, if the operator is alphanumeric, it must be declared infix.

Attributes

Inherited from:
Checking

A hook to exclude selected symbols from double declaration check

A hook to exclude selected symbols from double declaration check

Attributes

Inherited from:
Checking
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