Definitions

dotty.tools.dotc.core.Definitions
See theDefinitions companion object
class Definitions

A class defining symbols and types of standard definitions

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Type members

Classlikes

object ArrayOf

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
ArrayOf.type

Extractor for context function types representing by-name parameters, of the form () ?=> T. Under purefunctions, this becomes () ?-> T or {r1, ..., rN} () ?-> T.

Extractor for context function types representing by-name parameters, of the form () ?=> T. Under purefunctions, this becomes () ?-> T or {r1, ..., rN} () ?-> T.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

An extractor for context function types As ?=> B, possibly with dependent refinements. Optionally returns a triple consisting of the argument types As, the result type B and a whether the type is an erased context function.

An extractor for context function types As ?=> B, possibly with dependent refinements. Optionally returns a triple consisting of the argument types As, the result type B and a whether the type is an erased context function.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object FunctionNOf

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object FunctionOf

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
FunctionOf.type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object MatchCase

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
MatchCase.type
object MultiArrayOf

An extractor for multi-dimensional arrays. Note that this will also extract the high bound if an element type is a wildcard upper-bounded by an array. E.g.

An extractor for multi-dimensional arrays. Note that this will also extract the high bound if an element type is a wildcard upper-bounded by an array. E.g.

Array[? <: Array[? <: Number]]

would match

MultiArrayOf(<? <: Number>, 2)

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
class PerRun[T](generate: Context ?=> T)

Attributes

Supertypes
class Object
trait Matchable
class Any

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Types

Value members

Concrete methods

def ClassType(arg: Type)(using Context): Type
def EnumType(sym: Symbol)(using Context): TypeRef

The enumeration type, goven a value of the enumeration

The enumeration type, goven a value of the enumeration

Attributes

def FunctionSymbol(n: Int, isContextual: Boolean, isImpure: Boolean)(using Context): Symbol
def FunctionType(n: Int, isContextual: Boolean, isImpure: Boolean)(using Context): TypeRef
def SpecializedTuple(base: Symbol, args: List[Type])(using Context): Symbol
def adjustForBoxedUnit(cls: ClassSymbol, parents: List[Type]): List[Type]

If it is BoxedUnit, remove java.io.Serializable from parents.

If it is BoxedUnit, remove java.io.Serializable from parents.

Attributes

def adjustForTuple(cls: ClassSymbol, tparams: List[TypeSymbol], parents: List[Type]): List[Type]

If cls is Tuple1..Tuple22, add the corresponding *: type as last parent to parents

If cls is Tuple1..Tuple22, add the corresponding *: type as last parent to parents

Attributes

Return underlying context function type (i.e. instance of an ContextFunctionN class) or NoType if none exists. The following types are considered as underlying types:

Return underlying context function type (i.e. instance of an ContextFunctionN class) or NoType if none exists. The following types are considered as underlying types:

  • the alias of an alias type
  • the instance or origin of a TypeVar (i.e. the result of a stripTypeVar)
  • the upper bound of a TypeParamRef in the current constraint

Attributes

def boxedType(tp: Type)(using Context): TypeRef

The type of the boxed class corresponding to primitive value type tp.

The type of the boxed class corresponding to primitive value type tp.

Attributes

def functionArity(tp: Type)(using Context): Int

Returns the erased type of the function class cls

Returns the erased type of the function class cls

  • FunctionN for N > 22 becomes FunctionXXL
  • FunctionN for 22 > N >= 0 remains as FunctionN
  • ContextFunctionN for N > 22 becomes FunctionXXL
  • ContextFunctionN for N <= 22 becomes FunctionN
  • anything else becomes a NoType

Attributes

When typing a primitive value class or AnyVal, we ignore the getClass member: it's supposed to be an override of the getClass defined on Any, but in dotty Any#getClass is polymorphic so it ends up being an overload. This is especially problematic because it means that when writing:

When typing a primitive value class or AnyVal, we ignore the getClass member: it's supposed to be an override of the getClass defined on Any, but in dotty Any#getClass is polymorphic so it ends up being an overload. This is especially problematic because it means that when writing:

1.asInstanceOf[Int & AnyRef].getClass

the getClass that returns Class[Int] defined in Int can be selected, but this call is specified to return classOf[Integer], see tests/run/t5568.scala.

FIXME: remove all the getClass methods defined in the standard library so we don't have to hot-patch it like this.

Attributes

def init()(using Context): Unit

A whitelist of Scala-2 classes that are known to be pure

A whitelist of Scala-2 classes that are known to be pure

Attributes

final def isCompiletime_S(sym: Symbol)(using Context): Boolean

Is an context function class.

Is an context function class.

  • ContextFunctionN for N >= 0

Attributes

Is tp an context function type?

Is tp an context function type?

Attributes

Is any function class where

Is any function class where

  • FunctionXXL
  • FunctionN for N >= 0
  • ContextFunctionN for N >= 0

Attributes

def isFunctionNType(tp: Type)(using Context): Boolean

Returns whether tp is an instance or a refined instance of:

Returns whether tp is an instance or a refined instance of:

  • scala.FunctionN
  • scala.ContextFunctionN

Attributes

Is a function class, or an impure function type alias

Is a function class, or an impure function type alias

Attributes

def isFunctionType(tp: Type)(using Context): Boolean

Returns whether tp is an instance or a refined instance of:

Returns whether tp is an instance or a refined instance of:

  • scala.FunctionN
  • scala.ContextFunctionN
  • PolyFunction

Attributes

def isInfix(sym: Symbol)(using Context): Boolean

Is synthesized symbol with alphanumeric name allowed to be used as an infix operator?

Is synthesized symbol with alphanumeric name allowed to be used as an infix operator?

Attributes

Is tp (an alias) of either a scala.FunctionN or a scala.ContextFunctionN instance?

Is tp (an alias) of either a scala.FunctionN or a scala.ContextFunctionN instance?

Attributes

Is a function class where

Is a function class where

  • FunctionN for N >= 0 and N != XXL

Attributes

def isSpecializableFunction(cls: ClassSymbol, paramTypes: List[Type], retType: Type)(using Context): Boolean
def isSpecializableFunctionSAM(paramTypes: List[Type], retType: Type)(using Context): Boolean

If the Single Abstract Method of a Function class has this type, is it specializable?

If the Single Abstract Method of a Function class has this type, is it specializable?

Attributes

def isSpecializableTuple(base: Symbol, args: List[Type])(using Context): Boolean

Is a synthetic function class

Is a synthetic function class

  • FunctionN for N > 22
  • ContextFunctionN for N >= 0

Attributes

def isTupleNType(tp: Type)(using Context): Boolean

Is this type a TupleN type?

Is this type a TupleN type?

Attributes

Returns

true if the dealiased type of tp is TupleN[T1, T2, ..., Tn]

def isValueSubClass(sym1: Symbol, sym2: Symbol): Boolean
def isValueSubType(tref1: TypeRef, tref2: TypeRef)(using Context): Boolean

Is either FunctionXXL or a class that will be erased to FunctionXXL

Is either FunctionXXL or a class that will be erased to FunctionXXL

  • FunctionXXL
  • FunctionN for N >= 22
  • ContextFunctionN for N >= 22

Attributes

def patchSource(sym: Symbol)(using Context): SourceFile

If sym is a patched library class, the source file of its patch class, otherwise NoSource

If sym is a patched library class, the source file of its patch class, otherwise NoSource

Attributes

A finalizer that patches standard library classes. It copies all non-private, non-synthetic definitions from patchCls to denot while changing their owners to denot. Before that it deletes any definitions of denot that have the same name as one of the copied definitions.

A finalizer that patches standard library classes. It copies all non-private, non-synthetic definitions from patchCls to denot while changing their owners to denot. Before that it deletes any definitions of denot that have the same name as one of the copied definitions.

If an object is present in both the original class and the patch class, it is not overwritten. Instead its members are copied recursively.

To avpid running into cycles on bootstrap, patching happens only if patchCls is read from a classfile.

Attributes

Lazy references to the root imports

Lazy references to the root imports

Attributes

Root types imported by default

Root types imported by default

Attributes

If cls is a class in the scala package, its name, otherwise EmptyTypeName

If cls is a class in the scala package, its name, otherwise EmptyTypeName

Attributes

def scalaClassName(ref: Type)(using Context): TypeName

If type ref refers to a class in the scala package, its name, otherwise EmptyTypeName

If type ref refers to a class in the scala package, its name, otherwise EmptyTypeName

Attributes

def tupleType(elems: List[Type]): Type
def tupleTypes(tp: Type, bound: Int)(using Context): Option[List[Type]]
def typeTag(tp: Type)(using Context): Name

The JVM tag for tp if it's a primitive, java.lang.Object otherwise.

The JVM tag for tp if it's a primitive, java.lang.Object otherwise.

Attributes

def unboxedType(tp: Type)(using Context): TypeRef

Modules whose members are in the default namespace and their module classes

Modules whose members are in the default namespace and their module classes

Attributes

Concrete fields

lazy val AnyClass: ClassSymbol

Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter) because after erasure the Any and AnyVal references get remapped to the Object methods which would result in a double binding assertion failure. Instead we do the following:

Note: We cannot have same named methods defined in Object and Any (and AnyVal, for that matter) because after erasure the Any and AnyVal references get remapped to the Object methods which would result in a double binding assertion failure. Instead we do the following:

  • Have some methods exist only in Any, and remap them with the Erasure denotation transformer to be owned by Object.
  • Have other methods exist only in Object. To achieve this, we synthesize all Any and Object methods; Object methods no longer get loaded from a classfile.

Attributes

lazy val Any_!=: TermSymbol
lazy val Any_##: TermSymbol
lazy val Any_==: TermSymbol

def getClassA >: this.type: Class[? <: A]

def getClassA >: this.type: Class[? <: A]

Attributes

lazy val ArrayModule: Symbol
lazy val ArrayType: TypeRef
lazy val Array_apply: Symbol
lazy val Array_clone: Symbol
lazy val Array_length: Symbol
lazy val Array_update: Symbol
lazy val BooleanType: TypeRef
lazy val Boolean_!: Symbol
lazy val Boolean_!=: Symbol
lazy val Boolean_&&: Symbol
lazy val Boolean_==: Symbol
lazy val Boolean_||: Symbol
lazy val BreakClass: Symbol
val ByteEnc: Int
lazy val ByteType: TypeRef
lazy val CLP_showError: Symbol
lazy val CapsModule: Symbol
lazy val Caps_Cap: TypeSymbol
val CharEnc: Int
lazy val CharType: TypeRef
lazy val ConsClass: Symbol
val DoubleEnc: Int
lazy val DoubleType: TypeRef
lazy val Enum_ordinal: Symbol
val FloatEnc: Int
lazy val FloatType: TypeRef

A type alias of Object used to represent any reference to Object in a Java signature, the secret sauce is that subtype checking treats it specially:

A type alias of Object used to represent any reference to Object in a Java signature, the secret sauce is that subtype checking treats it specially:

tp <:< FromJavaObject

is equivalent to:

tp <:< Any

This is useful to avoid usability problems when interacting with Java code where Object is the top type. This is safe because this type will only appear in signatures of Java definitions in positions where Object might appear, let's enumerate all possible cases this gives us:

  1. At the top level:

    // A.java void meth1(Object arg) {} void meth2(T arg) {} // T implicitly extends Object

    // B.scala meth1(1) // OK meth2(1) // OK

    This is safe even though Int is not a subtype of Object, because Erasure will detect the mismatch and box the value type.

  2. In a class type parameter:

    // A.java void meth3(scala.List arg) {} void meth4(scala.List arg) {}

    // B.scala meth3(ListInt) // OK meth4(ListInt) // OK

    At erasure, type parameters are removed and value types are boxed.

  3. As the type parameter of an array:

    // A.java void meth5(Object[] arg) {} void meth6(T[] arg) {}

    // B.scala meth5(ArrayInt) // error: Array[Int] is not a subtype of Array[Object] meth6(ArrayInt) // error: Array[Int] is not a subtype of Array[T & Object]

    This is a bit more subtle: at erasure, Arrays keep their type parameter, and primitive Arrays are not subtypes of reference Arrays on the JVM, so we can't pass an Array of Int where a reference Array is expected. Array is invariant in Scala, so meth5 is safe even if we use FromJavaObject, but generic Arrays are treated specially: we always add & Object (and here we mean the normal java.lang.Object type) to these types when they come from Java signatures (see translateJavaArrayElementType), this ensure that meth6 is safe to use.

  4. As the repeated argument of a varargs method:

    // A.java void meth7(Object... args) {} void meth8(T... args) {}

    // B.scala meth7(1) // OK (creates a reference array) meth8(1) // OK (creates a primitive array and copies it into a reference array at Erasure) val ai = ArrayInt meth7(ai: _) // OK (will copy the array at Erasure) meth8(ai: _) // OK (will copy the array at Erasure)

    Java repeated arguments are erased to arrays, so it would be safe to treat them in the same way: add an & Object to the parameter type to disallow passing primitives, but that would be very inconvenient as it is common to want to pass a primitive to an Object repeated argument (e.g. String.format("foo: %d", 1)). So instead we type them without adding the & Object and let ElimRepeated and Erasure take care of doing any necessary adaptation (note that adapting a primitive array to a reference array requires copying the whole array, so this transformation only preserves semantics if the callee does not try to mutate the varargs array which is a reasonable assumption to make).

  5. This mechanism is similar to ObjectTpeJavaRef in Scala 2, except that we create a new symbol with its own name, this is needed because this type can show up in inferred types and therefore needs to be preserved when pickling so that unpickled trees pass -Ycheck.

    Note that by default we pretty-print FromJavaObject as Object or simply omit it if it's the sole upper-bound of a type parameter, use -Yprint-debug to explicitly display it.

    Attributes

    lazy val Function0: Symbol
    lazy val Function1: Symbol
    lazy val Function2: Symbol
    lazy val IArrayModule: Symbol
    lazy val ImplicitScrutineeTypeSym: Symbol { type ThisName = TypeName; }
    lazy val InitModule: Symbol
    val IntEnc: Int
    lazy val IntType: TypeRef
    lazy val Int_*: Symbol
    lazy val Int_+: Symbol
    lazy val Int_-: Symbol
    lazy val Int_/: Symbol
    lazy val Int_<=: Symbol
    lazy val Int_==: Symbol
    lazy val Int_>=: Symbol
    lazy val IntoType: TypeSymbol
    lazy val LabelClass: Symbol

    Definitions used in Lazy Vals implementation

    Definitions used in Lazy Vals implementation

    Attributes

    lazy val ListClass: Symbol
    lazy val ListModule: Symbol
    val LongEnc: Int
    lazy val LongType: TypeRef
    lazy val Long_*: Symbol
    lazy val Long_+: Symbol
    lazy val Long_/: Symbol
    lazy val MetaAnnots: Set[Symbol]
    lazy val NilModule: Symbol
    lazy val NoInitClasses: Set[Symbol]

    Classes that are known not to have an initializer irrespective of whether NoInits is set. Note: FunctionXXLClass is in this set because if it is compiled by Scala2, it does not get a NoInit flag. But since it is introduced only at erasure, there's no chance for augmentScala2Traits to do anything on a class that inherits it. So it also misses an implementation class, which means that the usual scheme of calling a superclass init in the implementation class of a Scala2 trait gets screwed up. Therefore, it is mandatory that FunctionXXL is treated as a NoInit trait.

    Classes that are known not to have an initializer irrespective of whether NoInits is set. Note: FunctionXXLClass is in this set because if it is compiled by Scala2, it does not get a NoInit flag. But since it is introduced only at erasure, there's no chance for augmentScala2Traits to do anything on a class that inherits it. So it also misses an implementation class, which means that the usual scheme of calling a superclass init in the implementation class of a Scala2 trait gets screwed up. Therefore, it is mandatory that FunctionXXL is treated as a NoInit trait.

    Attributes

    lazy val NoneModule: Symbol

    Class symbols for which no class exist at runtime

    Class symbols for which no class exist at runtime

    Attributes

    lazy val Object_eq: TermSymbol
    lazy val Object_ne: TermSymbol

    A package in which we can place all methods and types that are interpreted specially by the compiler

    A package in which we can place all methods and types that are interpreted specially by the compiler

    Attributes

    lazy val PureClass: Symbol
    lazy val SeqModule: Symbol
    lazy val SeqType: TypeRef
    lazy val Seq_apply: Symbol
    lazy val Seq_drop: Symbol
    lazy val Seq_head: Symbol
    lazy val Seq_length: Symbol
    lazy val Seq_toSeq: Symbol

    Names of the root import symbols that can be hidden by other imports

    Names of the root import symbols that can be hidden by other imports

    Attributes

    val ShortEnc: Int
    lazy val ShortType: TypeRef

    The scala.runtime.stdLibPacthes package contains objects that contain defnitions that get added as members to standard library objects with the same name.

    The scala.runtime.stdLibPacthes package contains objects that contain defnitions that get added as members to standard library objects with the same name.

    Attributes

    lazy val StringAdd_+: Symbol
    lazy val StringModule: Symbol
    lazy val StringOps: Symbol
    lazy val String_+: TermSymbol
    lazy val SubType_refl: Symbol
    lazy val SysPackage: Symbol
    lazy val Sys_error: Symbol
    lazy val SystemModule: Symbol
    lazy val ToExprModule: Symbol
    lazy val Tuple1: ClassSymbol
    lazy val Tuple2: ClassSymbol
    lazy val TupleModule: Symbol
    lazy val TupleType: Array[TypeRef | Null]
    lazy val TupleTypeRef: TypeRef
    lazy val Tuple_cons: Symbol
    val UnitEnc: Int
    lazy val UnitType: TypeRef
    lazy val andType: TypeSymbol

    Experimental definitions that can nevertheless be accessed from a stable compiler if capture checking is enabled.

    Experimental definitions that can nevertheless be accessed from a stable compiler if capture checking is enabled.

    Attributes

    lazy val orType: TypeSymbol

    Base classes that are assumed to be pure for the purposes of capture checking. Every class inheriting from a pure baseclass is pure.

    Base classes that are assumed to be pure for the purposes of capture checking. Every class inheriting from a pure baseclass is pure.

    Attributes

    Methods in Object and Any that do not have a side effect

    Methods in Object and Any that do not have a side effect

    Attributes

    Non-inheritable lasses that are assumed to be pure for the purposes of capture checking,

    Non-inheritable lasses that are assumed to be pure for the purposes of capture checking,

    Attributes

    Lists core methods that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe

    Lists core methods that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe

    Attributes

    Lists core classes that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe

    Lists core classes that don't have underlying bytecode, but are synthesized on-the-fly in every reflection universe

    Attributes

    Method representing a throw

    Method representing a throw

    Attributes

    lazy val throwsAlias: Symbol
    lazy val topClasses: Set[Symbol]