dotty.tools.dotc.core

Type members

Classlikes

enum Atoms

Indicates the singleton types that a type must or may consist of.

Indicates the singleton types that a type must or may consist of.

Value parameters:
hi

The upper bound: all singleton types in the carrier type are guaranteed to be in this set If the underlying type of a singleton type is another singleton type, only the latter type ends up in the sets.

lo

The lower bound: singleton types in this set are guaranteed to be in the carrier type.

Realizability status

Realizability status

Companion:
class
class CheckRealizable(using x$1: Context)

Compute realizability status.

Compute realizability status.

A type T is realizable iff it is inhabited by non-null values. This ensures that its type members have good bounds (in the sense from DOT papers). A type projection T#L is legal if T is realizable, and can be understood as Scala 2's v.L forSome { val v: T }.

In general, a realizable type can have multiple inhabitants, hence it need not be stable (in the sense of Type.isStable).

Companion:
object
class ClassfileLoader(val classfile: AbstractFile) extends SymbolLoader
object Comments
object Constants
abstract class Constraint extends Showable

Constraint over undetermined type parameters. Constraints are built over values of the following types:

Constraint over undetermined type parameters. Constraints are built over values of the following types:

  • TypeLambda A constraint constrains the type parameters of a set of TypeLambdas
  • TypeParamRef The parameters of the constrained type lambdas
  • TypeVar Every constrained parameter might be associated with a TypeVar that has the TypeParamRef as origin.

Methods for adding constraints and solving them.

Methods for adding constraints and solving them.

What goes into a Constraint as opposed to a ConstrainHandler?

Constraint code is purely functional: Operations get constraints and produce new ones. Constraint code does not have access to a type-comparer. Anything regarding lubs and glbs has to be done elsewhere.

By comparison: Constraint handlers are parts of type comparers and can use their functionality. Constraint handlers update the current constraint as a side effect.

object ContextOps

Extension methods for contexts where we want to keep the ctx. syntax

Extension methods for contexts where we want to keep the ctx. syntax

object Contexts

This TypeError signals that completing denot encountered a cycle: it asked for denot.info (or similar), so it requires knowing denot already.

This TypeError signals that completing denot encountered a cycle: it asked for denot.info (or similar), so it requires knowing denot already.

Companion:
object
Companion:
class
object Decorators

This object provides useful implicit decorators for types defined elsewhere

This object provides useful implicit decorators for types defined elsewhere

Companion:
class

A class defining symbols and types of standard definitions

A class defining symbols and types of standard definitions

Companion:
object

Denotations represent the meaning of symbols and named types. The following diagram shows how the principal types of denotations and their denoting entities relate to each other. Lines ending in a down-arrow v are member methods. The two methods shown in the diagram are "symbol" and "deref". Both methods are parameterized by the current context, and are effectively indexed by current period.

Denotations represent the meaning of symbols and named types. The following diagram shows how the principal types of denotations and their denoting entities relate to each other. Lines ending in a down-arrow v are member methods. The two methods shown in the diagram are "symbol" and "deref". Both methods are parameterized by the current context, and are effectively indexed by current period.

Lines ending in a horizontal line mean subtyping (right is a subtype of left).

NamedType | Symbol---------ClassSymbol | | | | denot | denot | denot v v v Denotation-+-----SingleDenotation-+------SymDenotation-+----ClassDenotation | | +-----MultiDenotation | | +--UniqueRefDenotation +--JointRefDenotation

Here's a short summary of the classes in this diagram.

NamedType A type consisting of a prefix type and a name, with fields prefix: Type name: Name It has two subtypes: TermRef and TypeRef Symbol A label for a definition or declaration in one compiler run ClassSymbol A symbol representing a class Denotation The meaning of a named type or symbol during a period MultiDenotation A denotation representing several overloaded members SingleDenotation A denotation representing a non-overloaded member or definition, with main fields symbol: Symbol info: Type UniqueRefDenotation A denotation referring to a single definition with some member type JointRefDenotation A denotation referring to a member that could resolve to several definitions SymDenotation A denotation representing a single definition with its original type, with main fields name: Name owner: Symbol flags: Flags privateWithin: Symbol annotations: List[Annotation] ClassDenotation A denotation representing a single class definition.

A type comparer that can record traces of subtype operations

A type comparer that can record traces of subtype operations

object Flags
sealed abstract class GadtConstraint extends Showable

Represents GADT constraints currently in scope

Represents GADT constraints currently in scope

object Hashable
Companion:
class
trait Hashable
Companion:
object

This module defines methods to interpret types of Java symbols, which are implicitly nullable in Java, as Scala types, which are explicitly nullable.

This module defines methods to interpret types of Java symbols, which are implicitly nullable in Java, as Scala types, which are explicitly nullable.

The transformation is (conceptually) a function n that adheres to the following rules: (1) n(T) = T | Null if T is a reference type (2) n(T) = T if T is a value type (3) n(C[T]) = C[T] | Null if C is Java-defined (4) n(C[T]) = C[n(T)] | Null if C is Scala-defined (5) n(A|B) = n(A) | n(B) | Null (6) n(A&B) = n(A) & n(B) (7) n((A1, ..., Am)R) = (n(A1), ..., n(Am))n(R) for a method with arguments (A1, ..., Am) and return type R (8) n(T) = T otherwise

Treatment of generics (rules 3 and 4):

  • if C is Java-defined, then n(C[T]) = C[T] | Null. That is, we don't recurse on the type argument, and only add Null on the outside. This is because C itself will be nullified, and in particular so will be usages of C's type argument within C's body. e.g. calling get on a java.util.List[String] already returns String|Null and not String, so we don't need to write java.util.List[String | Null].
  • if C is Scala-defined, however, then we want n(C[T]) = C[n(T)] | Null. This is because C won't be nullified, so we need to indicate that its type argument is nullable.

Notice that since the transformation is only applied to types attached to Java symbols, it doesn't need to handle the full spectrum of Scala types. Additionally, some kinds of symbols like constructors and enum instances get special treatment.

class MalformedType(pre: Type, denot: Denotation, absMembers: Set[Name]) extends TypeError

A utility module to produce match type reduction traces in error messages.

A utility module to produce match type reduction traces in error messages.

class MissingType(pre: Type, name: Name) extends TypeError
final case class Mode(bits: Int) extends AnyVal

A collection of mode bits that are part of a context

A collection of mode bits that are part of a context

Companion:
object
object Mode
Companion:
class
object NameKinds

Defines possible kinds of NameInfo of a derived name

Defines possible kinds of NameInfo of a derived name

object NameOps
object NameTags extends NameTags

The possible tags of a NameKind

The possible tags of a NameKind

object NamerOps

Operations that are shared between Namer and TreeUnpickler

Operations that are shared between Namer and TreeUnpickler

object Names
class NoLoader extends SymbolLoader with NoCompleter

A NoCompleter which is also a SymbolLoader.

A NoCompleter which is also a SymbolLoader.

Defines operations on nullable types and tree.

Defines operations on nullable types and tree.

Companion:
class
class OrderingConstraint(boundsMap: ParamBounds, lowerMap: ParamOrdering, upperMap: ParamOrdering) extends Constraint

Constraint over undetermined type parameters that keeps separate maps to reflect parameter orderings.

Constraint over undetermined type parameters that keeps separate maps to reflect parameter orderings.

Value parameters:
boundsMap

a map from TypeLambda to arrays. Each array contains twice the number of entries as there a type parameters in the TypeLambda. The first half of the array contains the type bounds that constrain the lambda's type parameters. The second half might contain type variables that track the corresponding parameters, or is left empty (filled with nulls). An instantiated type parameter is represented by having its instance type in the corresponding array entry. The dual use of arrays for poly params and typevars is to save space and hopefully gain some speed.

lowerMap

a map from TypeLambdas to arrays. Each array entry corresponds to a parameter P of the type lambda; it contains all constrained parameters Q that are known to be smaller than P, i.e. Q <: P.

upperMap

a map from TypeLambdas to arrays. Each array entry corresponds to a parameter P of the type lambda; it contains all constrained parameters Q that are known to be greater than P, i.e. P <: Q.

Companion:
object
trait ParamInfo

A common super trait of Symbol and LambdaParam. Used to capture the attributes of type parameters which can be implemented as either.

A common super trait of Symbol and LambdaParam. Used to capture the attributes of type parameters which can be implemented as either.

Companion:
object
object ParamInfo
Companion:
class
object Periods
object Phases
class RecursionOverflow(val op: String, details: => String, val previous: Throwable, val weight: Int) extends TypeError
object Scopes
case class Signature(paramsSig: List[ParamSig], resSig: TypeName)

The signature of a denotation.

The signature of a denotation.

Same-named denotations with different signatures are considered to be overloads, see SingleDenotation#matches for more details.

A method signature (a value of type Signature, excluding NotAMethod and OverloadedSignature) is composed of a list of parameter signatures, plus a type signature for the final result type.

A parameter signature (a value of type ParamSig) is either an integer, representing the number of type parameters in a type parameter section, or the type signature of a term parameter.

A type signature is the fully qualified name of the type symbol of the type's erasure.

For instance a definition

def f[T, S](x: Int)(y: List[T]): S

would have signature

Signature(
  List(2, "scala.Int".toTypeName, "scala.collection.immutable.List".toTypeName),
  "java.lang.Object".toTypeName)

Note that paramsSig has one entry for a whole type parameter section but one entry for each term parameter (currently, methods in Dotty can only have one type parameter section but this encoding leaves the door open for supporting multiple sections).

The signatures of non-method types are always NotAMethod.

There are three kinds of "missing" parts of signatures:

  • tpnme.EMPTY Result type marker for NotAMethod and OverloadedSignature
  • tpnme.WILDCARD Arises from a Wildcard or error type
  • tpnme.Uninstantiated Arises from an uninstantiated type variable
Companion:
object
object Signature
Companion:
class

The language in which the definition being erased was written.

The language in which the definition being erased was written.

Companion:
object
Companion:
class
class SourcefileLoader(val srcfile: AbstractFile) extends SymbolLoader
object StdNames

Substitution operations on types. See the corresponding subst and substThis methods on class Type for an explanation.

Substitution operations on types. See the corresponding subst and substThis methods on class Type for an explanation.

abstract class SymbolLoader extends LazyType

A lazy type that completes itself by calling parameter doComplete. Any linked modules/classes or module classes are also initialized.

A lazy type that completes itself by calling parameter doComplete. Any linked modules/classes or module classes are also initialized.

object Symbols
class TrackingTypeComparer(initctx: Context) extends TypeComparer
Companion:
class
final class TypeApplications(val self: Type) extends AnyVal

A decorator that provides methods for modeling type application

A decorator that provides methods for modeling type application

Companion:
object

Provides methods to compare types.

Provides methods to compare types.

Companion:
object
Companion:
class

Erased types are:

Erased types are:

ErasedValueType TypeRef(prefix is ignored, denot is ClassDenotation) TermRef(prefix is ignored, denot is SymDenotation) JavaArrayType AnnotatedType MethodType ThisType SuperType ClassInfo (NoPrefix, ...) NoType NoPrefix WildcardType ErrorType

only for isInstanceOf, asInstanceOf: PolyType, TypeParamRef, TypeBounds

Companion:
class
class TypeErasure(sourceLanguage: SourceLanguage, semiEraseVCs: Boolean, isConstructor: Boolean, isSymbol: Boolean, wildcardOK: Boolean)
Value parameters:
isConstructor

Argument forms part of the type of a constructor

isSymbol

If true, the type being erased is the info of a symbol.

semiEraseVCs

If true, value classes are semi-erased to ErasedValueType (they will be fully erased in ElimErasedValueType). If false, they are erased like normal classes.

sourceLanguage

Adapt our erasure rules to mimic what the given language would do.

wildcardOK

Wildcards are acceptable (true when using the erasure for computing a signature name).

Companion:
object
class TypeError(msg: String) extends Exception
object TypeOps
object TyperState
Companion:
class
class TyperState()
Companion:
object
object Types

When calling Constraint#addLess(p1, p2, ...), the caller might end up unifying one parameter with the other, this enum lets addLess know which direction the unification will take.

When calling Constraint#addLess(p1, p2, ...), the caller might end up unifying one parameter with the other, this enum lets addLess know which direction the unification will take.

class Uniques extends WeakHashSet[Type]
Companion:
object
object Uniques

Defines operation unique for hash-consing types. Also defines specialized hash sets for hash consing uniques of a specific type. All sets offer a enterIfNew method which checks whether a type with the given parts exists already and creates a new one if not.

Defines operation unique for hash-consing types. Also defines specialized hash sets for hash consing uniques of a specific type. All sets offer a enterIfNew method which checks whether a type with the given parts exists already and creates a new one if not.

Companion:
class
object Variances

Post-process exceptions that might result from StackOverflow to add tracing information while unwalking the stack.

Post-process exceptions that might result from StackOverflow to add tracing information while unwalking the stack.