Checking

dotty.tools.dotc.typer.Checking
See theChecking companion trait
object Checking

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Checking.type

Members list

Type members

Classlikes

class CheckNonCyclicMap(sym: Symbol, reportErrors: Boolean)(using x$3: Context) extends TypeMap

A type map which checks that the only cycles in a type are F-bounds and that protects all F-bounded references by LazyRefs.

A type map which checks that the only cycles in a type are F-bounds and that protects all F-bounded references by LazyRefs.

Attributes

Supertypes
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
Show all

Value members

Concrete methods

def checkAppliedType(tree: AppliedTypeTree, tpt: Tree)(using Context): Unit

Check applied type trees for well-formedness. This means

Check applied type trees for well-formedness. This means

  • all arguments are within their corresponding bounds
  • if type is a higher-kinded application with wildcard arguments, check that it or one of its supertypes can be reduced to a normal application. Unreducible applications correspond to general existentials, and we cannot handle those.

Value parameters

tpt

If tree is synthesized from a type in a TypeTree, the original TypeTree, or EmptyTree otherwise.

tree

The applied type tree to check

Attributes

Check all applied type trees in inferred type tpt for well-formedness

Check all applied type trees in inferred type tpt for well-formedness

Attributes

def checkBounds(args: List[Tree], boundss: List[TypeBounds], instantiate: (Type, List[Type]) => Type, app: Type, tpt: Tree)(using Context): Unit

A general checkBounds method that can be used for TypeApply nodes as well as for AppliedTypeTree nodes. Also checks that type arguments to *-type parameters are fully applied.

A general checkBounds method that can be used for TypeApply nodes as well as for AppliedTypeTree nodes. Also checks that type arguments to *-type parameters are fully applied.

Value parameters

tpt

If bounds are checked for an AppliedType, the type tree representing or (in case it is inferred) containing the type. See TypeOps.boundsViolations for an explanation of the first four parameters.

Attributes

def checkBounds(args: List[Tree], tl: TypeLambda)(using Context): Unit

Check that type arguments args conform to corresponding bounds in tl Note: This does not check the bounds of AppliedTypeTrees. These are handled by method checkAppliedType below.

Check that type arguments args conform to corresponding bounds in tl Note: This does not check the bounds of AppliedTypeTrees. These are handled by method checkAppliedType below.

Attributes

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

Check that experimental language imports in trees are done only in experimental scopes, or in a top-level scope with only @experimental definitions.

Check that experimental language imports in trees are done only in experimental scopes, or in a top-level scope with only @experimental definitions.

Attributes

Check the inline override methods only use inline parameters if they override an inline parameter.

Check the inline override methods only use inline parameters if they override an inline parameter.

Attributes

def checkInstantiable(tp: Type, srcTp: Type, pos: SrcPos)(using Context): Unit

Check that tp refers to a nonAbstract class and that the instance conforms to the self type of the created class.

Check that tp refers to a nonAbstract class and that the instance conforms to the self type of the created class.

Attributes

Check the type signature of the symbol M defined by tree does not refer to a private type or value which is invisible at a point where M is still visible.

Check the type signature of the symbol M defined by tree does not refer to a private type or value which is invisible at a point where M is still visible.

As an exception, we allow references to type aliases if the underlying type of the alias is not a leak, and if sym is not a type. The rationale for this is that the inferred type of a term symbol might contain leaky aliases which should be removed (see leak-inferred.scala for an example), but a type symbol definition will not contain leaky aliases unless the user wrote them, so we can ask the user to change his definition. The more practical reason for not transforming types is that checkNoPrivateLeaks can force a lot of denotations, and this restriction means that we never need to run TypeAssigner#avoidPrivateLeaks on type symbols when unpickling, which avoids some issues related to forcing order.

See i997.scala for negative tests, and i1130.scala for a case where it matters that we transform leaky aliases away.

Attributes

Returns

The info of sym, with problematic aliases expanded away.

def checkNoWildcard(tree: Tree)(using Context): Tree
def checkNonCyclic(sym: Symbol, info: Type, reportErrors: Boolean)(using Context): Type

Check that info of symbol sym is not cyclic.

Check that info of symbol sym is not cyclic.

Attributes

Returns

info where every legal F-bounded reference is protected by a LazyRef, or ErrorType if a cycle was detected and reported.

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

Check type members inherited from different parents of joint type for cycles, unless a type with the same name already appears in decls.

Check type members inherited from different parents of joint type for cycles, unless a type with the same name already appears in decls.

Attributes

Returns

true iff no cycles were detected

Check that users do not extend the PolyFunction trait. We only allow compiler generated PolyFunctions.

Check that users do not extend the PolyFunction trait. We only allow compiler generated PolyFunctions.

Attributes

def checkPolyFunctionType(tree: Tree)(using Context): Unit

Checks that PolyFunction only have valid refinements.

Checks that PolyFunction only have valid refinements.

It only supports apply methods with one parameter list and optional type arguments.

Attributes

def checkRealizable(tp: Type, pos: SrcPos, what: String)(using Context): Unit

Check that type tp is realizable.

Check that type tp is realizable.

Attributes

def checkRefinementNonCyclic(refinement: Tree, refineCls: ClassSymbol, seen: Set[Symbol])(using Context): Unit

Check that refinement satisfies the following two conditions

Check that refinement satisfies the following two conditions

  1. No part of it refers to a symbol that's defined in the same refinement at a textually later point.
  2. All references to the refinement itself via this are followed by selections. Note: It's not yet clear what exactly we want to allow and what we want to rule out. This depends also on firming up the DOT calculus. For the moment we only issue deprecated warnings, not errors.

Attributes

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

Under -Yrequire-targetName, if sym has an operator name, check that it has a

Under -Yrequire-targetName, if sym has an operator name, check that it has a

Attributes

def checkValue(tree: Tree)(using Context): Unit
def checkValue(tree: Tree, proto: Type)(using Context): tree.type

Check that tree refers to a value, unless tree is selected or applied (singleton types x.type don't count as selections).

Check that tree refers to a value, unless tree is selected or applied (singleton types x.type don't count as selections).

Attributes

def checkWellFormed(sym: Symbol)(using Context): Unit

Check that symbol's definition is well-formed.

Check that symbol's definition is well-formed.

Attributes

Check for illegal or redundant modifiers on modules. This is done separately from checkWellformed, since the original module modifiers don't surivive desugaring

Check for illegal or redundant modifiers on modules. This is done separately from checkWellformed, since the original module modifiers don't surivive desugaring

Attributes

def preCheckKind(arg: Tree, paramBounds: Type)(using Context): Tree

Check that kind of arg has the same outline as the kind of paramBounds. E.g. if paramBounds has kind * -> *, arg must have that kind as well, and analogously for all other kinds. This kind checking does not take into account variances or bounds. The more detailed kind checking is done as part of checkBounds in PostTyper. The purpose of preCheckKind is to do a rough test earlier in Typer, in order to prevent scenarios that lead to self application of types. Self application needs to be avoided since it can lead to stack overflows. Test cases are neg/i2771.scala and neg/i2771b.scala. A NoType paramBounds is used as a sign that checking should be suppressed.

Check that kind of arg has the same outline as the kind of paramBounds. E.g. if paramBounds has kind * -> *, arg must have that kind as well, and analogously for all other kinds. This kind checking does not take into account variances or bounds. The more detailed kind checking is done as part of checkBounds in PostTyper. The purpose of preCheckKind is to do a rough test earlier in Typer, in order to prevent scenarios that lead to self application of types. Self application needs to be avoided since it can lead to stack overflows. Test cases are neg/i2771.scala and neg/i2771b.scala. A NoType paramBounds is used as a sign that checking should be suppressed.

Attributes

def preCheckKinds(args: List[Tree], paramBoundss: List[Type])(using Context): List[Tree]