Capabilities

dotty.tools.dotc.cc.Capabilities
object Capabilities

Capabilities are members of capture sets. They partially overlap with types as shown in the trait hierarchy below.

Capability --+-- RootCapabilty -----+-- GlobalCap --------+-- GlobalAny | | +-- GlobalFresh | +-- LocalCap | +-- ResultCap | +-- CoreCapability ----+-- ObjectCapability --+-- TermRef | | +-- ThisType | | +-- TermParamRef | | | +-- SetCapability -----+-- TypeRef | +-- TypeParamRef | +-- DerivedCapability -+-- Reach +-- Only +-- ReadOnly +-- Maybe

All CoreCapabilities are Types, or, more specifically instances of TypeProxy.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Classlikes

abstract class CapMap(using x$1: Context) extends BiTypeMap

Attributes

Supertypes
trait BiTypeMap
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
Show all
Known subtypes
class ToResult
trait Capability extends Showable

A trait for references in CaptureSets. These can be NamedTypes, ThisTypes or ParamRefs, as well as three kinds of AnnotatedTypes representing readOnly, reach, and maybe capabilities. If there are several annotations they come with an order: * first, .only next, .rd next, ? last.

A trait for references in CaptureSets. These can be NamedTypes, ThisTypes or ParamRefs, as well as three kinds of AnnotatedTypes representing readOnly, reach, and maybe capabilities. If there are several annotations they come with an order: * first, .only next, .rd next, ? last.

Attributes

Supertypes
trait Showable
class Object
trait Matchable
class Any
Known subtypes
class TermParamRef
class TermRef
class ThisType
class TypeParamRef
class TypeRef
class ParamRef
class Maybe
class Reach
class ReadOnly
class Restricted
class GlobalCap
object GlobalAny
object GlobalFresh
class LocalCap
class ResultCap
Show all

Result type of transClassifiers. Interprete as follows: UnknownClassifier: No list could be computed since some capture sets are still unsolved variables Unclassified : No set exists since some parts of tcs are not classified ClassifiedAs(clss: All parts of tcss are classified with classes in clss

Result type of transClassifiers. Interprete as follows: UnknownClassifier: No list could be computed since some capture sets are still unsolved variables Unclassified : No set exists since some parts of tcs are not classified ClassifiedAs(clss: All parts of tcss are classified with classes in clss

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

The base trait of all capabilities represented as types

The base trait of all capabilities represented as types

Attributes

Supertypes
trait Capability
class TypeProxy
class Type
trait Showable
trait Hashable
class Object
trait Matchable
class Any
Show all
Known subtypes
class TermParamRef
class TermRef
class ThisType
class TypeParamRef
class TypeRef
class ParamRef
Show all

Attributes

Supertypes
trait Capability
trait Showable
class Object
trait Matchable
class Any
Known subtypes
class Maybe
class Reach
class ReadOnly
class Restricted
class FreshCapToResult(using x$1: Context) extends TypeMap

Map GlobalFresh capabilities in results of methods to ResultCaps This map is peculiar since it has to run very early in Setup where some capture sets are not yet known and consequently map in CaptureSet might give wrong results. A test case where this would happen is neg-custom-args/captures/i13816.scala This motivates the various tricks explained below.

Map GlobalFresh capabilities in results of methods to ResultCaps This map is peculiar since it has to run very early in Setup where some capture sets are not yet known and consequently map in CaptureSet might give wrong results. A test case where this would happen is neg-custom-args/captures/i13816.scala This motivates the various tricks explained below.

Attributes

Supertypes
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
Show all
object GlobalAny extends GlobalCap

The global root capability referenced as caps.any

The global root capability referenced as caps.any

Attributes

Supertypes
class GlobalCap
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all
Self type
GlobalAny.type
class GlobalCap(val fullName: String) extends RootCapability

A class for the global root capabilities referenced as caps.any and caps.fresh. They do not subsume other capabilities, except in arguments of withCapAsRoot calls.

A class for the global root capabilities referenced as caps.any and caps.fresh. They do not subsume other capabilities, except in arguments of withCapAsRoot calls.

Attributes

Supertypes
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all
Known subtypes
object GlobalAny
object GlobalFresh
class GlobalCapToLocal(origin: Origin)(using x$2: Context) extends BiTypeMap, FollowAliasesMap

Map each occurrence of caps.any to a different LocalCap instance Exception: CapSet^ stays as it is.

Map each occurrence of caps.any to a different LocalCap instance Exception: CapSet^ stays as it is.

Attributes

Supertypes
trait BiTypeMap
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
Show all
Self type
object GlobalFresh extends GlobalCap

The global root capability referenced as caps.fresh

The global root capability referenced as caps.fresh

Attributes

Supertypes
class GlobalCap
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all
Self type
class Internalize(binder: MethodType)(using x$2: Context) extends BiTypeMap

The local dual of a result type of a closure type.

The local dual of a result type of a closure type.

Value parameters

binder

the method type of the anonymous function whose result is mapped

Attributes

Supertypes
trait BiTypeMap
class TypeMap
trait Type => Type
class Object
trait Matchable
class Any
Show all
Self type
case class LocalCap(prefix: Type)(owner: Symbol, origin: Origin, origHidden: HiddenSet | Null)(using ctx: Context) extends RootCapability

The class of local roots named "any". These do subsume other capabilties in scope. They track with hidden sets which other capabilities were subsumed. Hidden sets are inspected by separation checking.

The class of local roots named "any". These do subsume other capabilties in scope. They track with hidden sets which other capabilities were subsumed. Hidden sets are inspected by separation checking.

Value parameters

origin

an indication where and why the LocalCap was created, used for diagnostics

owner

the owner of the context in which the LocalCap was created

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all
object LocalCap

Attributes

Companion
class
Supertypes
class Object
trait Matchable
class Any
Self type
LocalCap.type
case class Maybe(underlying: Capability) extends DerivedCapability

If x is a capability, its maybe capability x?. x? stands for a capability x that might or might not be part of a capture set. We have `{} : C^{} <: C^{x}]

If x is a capability, its maybe capability x?. x? stands for a capability x that might or might not be part of a capture set. We have `{} : C^{} <: C^{x}]

but it has fewer issues with type inference.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
trait Capability
class TypeProxy
class Type
trait Showable
trait Hashable
class Object
trait Matchable
class Any
Show all
Known subtypes
class TermParamRef
class TermRef
class ThisType
enum Origin

The place of - and cause for - creating a LocalCap capability. Used for error diagnostics

The place of - and cause for - creating a LocalCap capability. Used for error diagnostics

Attributes

Supertypes
trait Enum
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class Reach(underlying: ObjectCapability) extends DerivedCapability

If x is a capability, its reach capability x*. x* stands for all capabilities reachable through x. We have {x} &lt;: {x*} &lt;: dcs(x)} where the deep capture set dcs(x) of x is the union of all capture sets that appear in covariant position in the type of x. If x and y are different variables then {x*} and {y*} are unrelated.

If x is a capability, its reach capability x*. x* stands for all capabilities reachable through x. We have {x} &lt;: {x*} &lt;: dcs(x)} where the deep capture set dcs(x) of x is the union of all capture sets that appear in covariant position in the type of x. If x and y are different variables then {x*} and {y*} are unrelated.

Reach capabilities cannot wrap read-only capabilities or maybe capabilities. We have (x?).reach = (x.reach)? (x.rd).reach = (x.reach).rd (x.only[T]).reach = (x*).only[T]

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all

The readonly capability x.rd. We have {x.rd} <: {x}.

The readonly capability x.rd. We have {x.rd} <: {x}.

Read-only capabilities cannot wrap maybe capabilities but they can wrap reach capabilities. We have (x?).readOnly = (x.rd)?

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all
case class Restricted(underlying: CoreCapability | RootCapability | Reach, cls: ClassSymbol) extends DerivedCapability

The restricted capability x.only[C]. We have {x.only[C]} <: {x}.

The restricted capability x.only[C]. We have {x.only[C]} <: {x}.

Restricted capabilities cannot wrap maybe capabilities or read-only capabilities but they can wrap reach capabilities. We have (x?).restrict[T] = (x.restrict[T])? (x.rd).restrict[T] = (x.restrict[T]).rd

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all
case class ResultCap(binder: MethodicType) extends RootCapability

A root capability associated with a function type. These are conceptually existentially quantified over the function's result type.

A root capability associated with a function type. These are conceptually existentially quantified over the function's result type.

Value parameters

binder

The function type with which the capability is associated. It is a MethodicType since we also have ResultCaps that are associated with the ExprTypes of parameterless functions. Currently we never create results over PolyTypes since a PolyType used as a type (not a method info) is always followed by a MethodType. Setup: In the setup phase, fresh instances in the result of a dependent function type or method type such as (x: T): C^{fresh} are converted to ResultCap(binder) instances, where binder refers to the immediately enclosing method type. If one needs to refer to an outer method type as the binder instead, one can achieve that by using a type alias. For instance: type F[X^] = (x: A) => C^{X} () => F[{fresh}] With explicit quantification, this would be equivalent to () => \exists fresh. (x: A) => C^{fresh} The trick is that the argument fresh is bound before the F alias is expanded.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
trait Capability
trait Showable
class Object
trait Matchable
class Any
Show all
trait RootCapability extends Capability

The base trait of all root capabilities

The base trait of all root capabilities

Attributes

Supertypes
trait Capability
trait Showable
class Object
trait Matchable
class Any
Known subtypes
class GlobalCap
object GlobalAny
object GlobalFresh
class LocalCap
class ResultCap

Attributes

Supertypes
trait Capability
class TypeProxy
class Type
trait Showable
trait Hashable
class Object
trait Matchable
class Any
Show all
Known subtypes
class TypeParamRef
class TypeRef
class ToResult(localResType: Type, mt: MethodicType, sym: Symbol, fail: Message => Unit)(using x$5: Context) extends CapMap

Attributes

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

Types

opaque type Validity

Value members

Concrete methods

def currentId(using Context): Validity

The smallest list D of class symbols in cs1 and cs2 such that every class symbol in cs1 and cs2 is a subclass of a class symbol in D

The smallest list D of class symbols in cs1 and cs2 such that every class symbol in cs1 and cs2 is a subclass of a class symbol in D

Attributes

def globalCapToLocal(tp: Type, origin: Origin)(using Context): Type

Maps caps.any to LocalCap instances. GlobalCapToLocal is a BiTypeMap since we don't want to freeze a set when it is mapped. On the other hand, we do not want LocalCap values to flow back to caps.any since that would fail disallowRootCapability tests elsewhere. We therefore use withNoVarsMapped to prevent the map being installed for future use.

Maps caps.any to LocalCap instances. GlobalCapToLocal is a BiTypeMap since we don't want to freeze a set when it is mapped. On the other hand, we do not want LocalCap values to flow back to caps.any since that would fail disallowRootCapability tests elsewhere. We therefore use withNoVarsMapped to prevent the map being installed for future use.

Attributes

The least classifier between cls1 and cls2, which are either AnyClass, NothingClass, or a class directly extending caps.Classifier.

The least classifier between cls1 and cls2, which are either AnyClass, NothingClass, or a class directly extending caps.Classifier.

Attributes

Returns

if one of cls1, cls2 is a subclass of the other, the subclass otherwise NothingClass (which is a subclass of all classes)

def localCapToGlobal(param: Symbol, tp: Type)(using Context): Type

Maps all LocalCap instances to caps.any

Maps all LocalCap instances to caps.any

Attributes

def resultToAny(tp: Type, origin: Origin)(using Context): Type

Map top-level free ResultCaps one-to-one to LocalCap instances

Map top-level free ResultCaps one-to-one to LocalCap instances

Attributes

def toResult(tp: Type, mt: MethodicType, sym: Symbol, fail: Message => Unit)(using Context): Type

Replace all occurrences of caps.any or LocalCap in parts of this type by an existentially bound variable bound by mt. Stop at function or method types since these have been mapped before.

Replace all occurrences of caps.any or LocalCap in parts of this type by an existentially bound variable bound by mt. Stop at function or method types since these have been mapped before.

Attributes

def validId(runId: RunId, iterId: Int): Validity

Concrete fields

Exports

Defined exports

final type ClassifiedAs = ClassifiedAs
Exported from Classifiers$