TypeOps

object TypeOps
class Object
trait Matchable
class Any

Type members

Classlikes

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

The TypeMap handling the asSeenFrom

The TypeMap handling the asSeenFrom

class SimplifyKeepUnchecked(using `x$1`: Context) extends SimplifyMap
class SimplifyMap(using `x$1`: Context) extends TypeMap

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

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.

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. We need to approximate with ranges:

An upper approximation of the given type tp that does not refer to any symbol in symsToAvoid. 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, this types of classes in symsToAvoid.

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

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.

Value Params
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 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.
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
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.

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.

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

Implementation of Types#simplified

Implementation of Types#simplified

Concrete fields