TypeOps

dotty.tools.dotc.core.TypeOps$
object TypeOps

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
TypeOps.type

Members list

Concise view

Type members

Classlikes

class AsSeenFromMap(pre: Type, cls: Symbol)(using x$3: Context) extends ApproximatingTypeMap with IdempotentCaptRefMap

The TypeMap handling the asSeenFrom

The TypeMap handling the asSeenFrom

Attributes

Graph
Supertypes
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
abstract class AvoidMap(using x$1: Context) extends AvoidWildcardsMap with IdempotentCaptRefMap

An approximating map that drops NamedTypes matching toAvoid and wildcard types.

An approximating map that drops NamedTypes matching toAvoid and wildcard types.

Attributes

Graph
Supertypes
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
Known subtypes
class SimplifyKeepUnchecked(using x$1: Context) extends SimplifyMap

Attributes

Graph
Supertypes
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
class SimplifyMap(using x$1: Context) extends IdentityCaptRefMap

Attributes

Graph
Supertypes
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
Known subtypes
class StripTypeVarsMap(using x$1: Context) extends TypeMap

Attributes

Graph
Supertypes
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any

Types

An argument bounds violation is a triple consisting of

An argument bounds violation is a triple consisting of

  • the argument tree
  • a string "upper" or "lower" indicating which bound is violated
  • the violated bound

Attributes

Value members

Concrete methods

final def asSeenFrom(tp: Type, pre: Type, cls: Symbol)(using Context): Type

The type tp as seen from prefix pre and owner cls. See the spec for what this means.

The type tp as seen from prefix pre and owner cls. See the spec for what this means.

Attributes

def avoid(tp: Type, symsToAvoid: => List[Symbol])(using Context): Type

An upper approximation of the given type tp that does not refer to any symbol in symsToAvoid and does not contain any WildcardType. We need to approximate with ranges:

An upper approximation of the given type tp that does not refer to any symbol in symsToAvoid and does not contain any WildcardType. We need to approximate with ranges:

term references to symbols in symsToAvoid, term references that have a widened type of which some part refers to a symbol in symsToAvoid, type references to symbols in symsToAvoid,

Type variables that would be interpolated to a type that needs to be widened are replaced by the widened interpolation instance.

TODO: Could we replace some or all usages of this method by LevelAvoidMap instead? It would be good to investigate this in details but when I tried it, avoidance for inlined trees broke because TreeMap does not update ctx.nestingLevel when entering a block so I'm leaving this as Future Work™.

Attributes

def boundsViolations(args: List[Tree], boundss: List[TypeBounds], instantiate: (Type, List[Type]) => Type, app: Type)(using Context): List[BoundsViolation]

The list of violations where arguments are not within bounds.

The list of violations where arguments are not within bounds.

Attributes

app

The applied type whose arguments are checked, or NoType if arguments are for a TypeApply. This is particularly difficult for F-bounds that also contain wildcard arguments (see below). In fact the current treatment for this sitiuation can so far only be classified as "not obviously wrong", (maybe it still needs to be revised).

args

The arguments

boundss

The list of type bounds

instantiate

A function that maps a bound type and the list of argument types to a resulting type. Needed to handle bounds that refer to other bounds.

def childPrefix(pre: Type, parent: Symbol, child: Symbol)(using Context): Type

computes a prefix for child, derived from its common prefix with pre

computes a prefix for child, derived from its common prefix with pre

  • pre is assumed to be the prefix of parent at a given callsite.
  • child is assumed to be the sealed child of parent, and reachable according to whyNotGenericSum.

Attributes

def classBound(info: ClassInfo)(using Context): Type

An abstraction of a class info, consisting of

An abstraction of a class info, consisting of

  • the intersection of its parents,
  • refined by all non-private fields, methods, and type members,
  • abstracted over all type parameters (into a type lambda)
  • where all references to this of the class are closed over in a RecType.

Attributes

def isLegalPrefix(pre: Type)(using Context): Boolean

If tpe is of the form p.x where p refers to a package but x is not owned by a package, expand it to

If tpe is of the form p.x where p refers to a package but x is not owned by a package, expand it to

p.package.x

Attributes

def nestedPairs(ts: List[Type])(using Context): Type
def orDominator(tp: Type)(using Context): Type

Approximate union type by intersection of its dominators. That is, replace a union type Tn | ... | Tn by the smallest intersection type of base-class instances of T1,...,Tn. Example: Given

Approximate union type by intersection of its dominators. That is, replace a union type Tn | ... | Tn by the smallest intersection type of base-class instances of T1,...,Tn. Example: Given

trait C[+T]
trait D
class A extends C[A] with D
class B extends C[B] with D with E

we approximate A | B by C[A | B] with D.

Before we do that, we try to find a common non-class supertype of T1 | ... | Tn in a "best effort", ad-hoc way by selectively widening types in T1, ..., Tn and stopping if the resulting union simplifies to a type that is not a disjunction.

Attributes

def refineUsingParent(parent: Type, child: Symbol)(using Context): Type

Refine child based on parent

Refine child based on parent

In child class definition, we have:

class Child[Ts] extends path.Parent[Us] with Es
object Child extends path.Parent[Us] with Es
val child = new path.Parent[Us] with Es           // enum values

Given a parent type parent and a child symbol child, we infer the prefix and type parameters for the child:

prefix.child[Vs] <:< parent

where Vs are fresh type variables and prefix is the symbol prefix with all non-module and non-package ThisType replaced by fresh type variables.

If the subtyping is true, the instantiated type p.child[Vs] is returned. Otherwise, NoType is returned.

Attributes

def simplify(tp: Type, theMap: SimplifyMap | Null)(using Context): Type

Implementation of Types#simplified

Implementation of Types#simplified

Attributes

def stripTypeVars(tp: Type)(using Context): Type

Apply Type.stripTypeVar recursively.

Apply Type.stripTypeVar recursively.

Attributes

Concrete fields