dotty.tools.dotc.cc
Members list
Type members
Classlikes
Attributes
- Supertypes
- Known subtypes
-
object MaybeCapabilityobject ReachCapability
Capture checking state, which is known to other capture checking components
Capture checking state, which is known to other capture checking components
Attributes
- Supertypes
An annotation representing a capture set and whether it is boxed. It simulates a normal @retains annotation except that it is more efficient, supports variables as capture sets, and adds a boxed
flag. These annotations are created during capture checking. Before that there are only regular @retains and @retainsByName annotations.
An annotation representing a capture set and whether it is boxed. It simulates a normal @retains annotation except that it is more efficient, supports variables as capture sets, and adds a boxed
flag. These annotations are created during capture checking. Before that there are only regular @retains and @retainsByName annotations.
Value parameters
- boxed
-
whether the type carrying the annotation is boxed
- cls
-
the underlying class (either annotation.retains or annotation.retainsByName)
- refs
-
the capture set
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Annotationtrait Showableclass Objecttrait Matchableclass AnyShow all
A class for capture sets. Capture sets can be constants or variables. Capture sets support inclusion constraints <:< where <:< is subcapturing.
A class for capture sets. Capture sets can be constants or variables. Capture sets support inclusion constraints <:< where <:< is subcapturing.
They also allow
- mapping with functions from elements to capture sets
- filtering with predicates on elements
- intersecting wo capture sets
That is, constraints can be of the forms
cs1 <:< cs2 cs1 = ∪ {f(x) | x ∈ cs2} where f is a function from capture references to capture sets. cs1 = ∪ {x | x ∈ cs2, p(x)} where p is a predicate on capture references cs1 = cs2 ∩ cs2
We call the resulting constraint system "monadic set constraints". To support capture propagation across maps, mappings are supported only if the mapped function is either a bijection or if it is idempotent on capture references (c.f. doc comment on map
below).
Attributes
- Companion
- object
- Supertypes
- Known subtypes
-
class Constobject Fluidclass Varclass DerivedVarclass BiMappedclass Filteredclass Diffclass Mappedclass Intersectedclass RefiningVarShow all
Attributes
- Companion
- class
- Supertypes
- Self type
-
CaptureSet.type
A (possibly boxed) capturing type. This is internally represented as an annotated type with a @retains or @retainsByName annotation, but the extractor will succeed only at phase CheckCaptures. That way, we can ignore caturing information until phase CheckCaptures since it is wrapped in a plain annotation.
A (possibly boxed) capturing type. This is internally represented as an annotated type with a @retains or @retainsByName annotation, but the extractor will succeed only at phase CheckCaptures. That way, we can ignore caturing information until phase CheckCaptures since it is wrapped in a plain annotation.
The same trick does not work for the boxing information. Boxing is context dependent, so we have to add that information in the Setup step preceding CheckCaptures. Boxes are added for all type arguments of methods. For type arguments of applied types a different strategy is used where we box arguments of applied types that are not functions when accessing the argument.
An alternative strategy would add boxes also to arguments of applied types during setup. But this would have to be done for all possibly accessibly types from the compiled units as well as their dependencies. It's difficult to do this in a DenotationTransformer without accidentally forcing symbol infos. That's why this alternative was not implemented. If we would go back on this it would make sense to also treat captuyring types different from annotations and to generate them all during Setup and in DenotationTransformers.
Attributes
- Supertypes
- Self type
-
CapturingType.type
The capture checker
Attributes
- Companion
- object
- Supertypes
-
class Rechecktrait SymTransformertrait DenotTransformerclass Phaseclass Objecttrait Matchableclass AnyShow all
- Self type
An exception thrown if a @retains argument is not syntactically a CaptureRef
An exception thrown if a @retains argument is not syntactically a CaptureRef
Attributes
- Supertypes
An extractor for ref @maybeCapability
, which is used to express the maybe capability ref?
as a type.
An extractor for ref @maybeCapability
, which is used to express the maybe capability ref?
as a type.
Attributes
- Supertypes
- Self type
-
MaybeCapability.type
Attributes
- Supertypes
An extractor for ref @annotation.internal.reachCapability
, which is used to express the reach capability ref*
as a type.
An extractor for ref @annotation.internal.reachCapability
, which is used to express the reach capability ref*
as a type.
Attributes
- Supertypes
- Self type
-
ReachCapability.type
An extractor for caps.reachCapability(ref)
, which is used to express a reach capability as a tree in a @retains annotation.
An extractor for caps.reachCapability(ref)
, which is used to express a reach capability as a tree in a @retains annotation.
Attributes
- Supertypes
- Self type
-
ReachCapabilityApply.type
A builder and extractor for annotated types with @retains or @retainsByName annotations.
A builder and extractor for annotated types with @retains or @retainsByName annotations.
Attributes
- Supertypes
- Self type
-
RetainingType.type
A tree traverser that prepares a compilation unit to be capture checked. It does the following:
A tree traverser that prepares a compilation unit to be capture checked. It does the following:
- For every inferred type, drop any retains annotations, add capture sets to all its parts, add refinements to class types and function types. (c.f. mapInferred)
- For explicit capturing types, expand throws aliases to the underlying (pure) function, and add some implied capture sets to curried functions (c.f. expandThrowsAlias, expandAbbreviations).
- Add capture sets to self types of classes and objects, unless the self type was written explicitly.
- Box the types of mutable variables and type arguments to methods (type arguments of types are boxed on access).
- Link the external types of val and def symbols with the inferred types based on their parameter symbols.
Attributes
- Companion
- object
- Supertypes
-
trait SetupAPItrait SymTransformerclass PreRechecktrait DenotTransformerclass Phaseclass Objecttrait Matchableclass AnyShow all
- Self type
Classification and transformation methods for function methods and synthetic case class methods that need to be treated specially. In particular, compute capturing types for some of these methods which have inferred (result-)types that need to be established under separate compilation.
Classification and transformation methods for function methods and synthetic case class methods that need to be treated specially. In particular, compute capturing types for some of these methods which have inferred (result-)types that need to be established under separate compilation.
Attributes
- Supertypes
- Self type
-
Synthetics.type
Value members
Concrete methods
The currently valid CCState
The currently valid CCState
Attributes
A dependent function type with given arguments and result type TODO Move somewhere else where we treat all function type related ops together.
A dependent function type with given arguments and result type TODO Move somewhere else where we treat all function type related ops together.
Attributes
Are we at checkCaptures phase?
Are we at checkCaptures phase?
Attributes
Are we at checkCaptures or Setup phase?
Are we at checkCaptures or Setup phase?
Attributes
Extensions
Extensions
Does this symbol allow results carrying the universal capability? Currently this is true only for function type applies (since their results are unboxed) and erasedValue
since this function is magic in that is allows to conjure global capabilies from nothing (aside: can we find a more controlled way to achieve this?). But it could be generalized to other functions that so that they can take capability classes as arguments.
Does this symbol allow results carrying the universal capability? Currently this is true only for function type applies (since their results are unboxed) and erasedValue
since this function is magic in that is allows to conjure global capabilies from nothing (aside: can we find a more controlled way to achieve this?). But it could be generalized to other functions that so that they can take capability classes as arguments.
Attributes
Does this symbol define a level where we do not want to let local variables escape into outer capture sets?
Does this symbol define a level where we do not want to let local variables escape into outer capture sets?
Attributes
A class is pure if:
A class is pure if:
- one its base types has an explicitly declared self type with an empty capture set
- or it is a value class
- or it is an exception
- or it is one of Nothing, Null, or String
Attributes
This symbol is one of retains
or retainsCap
This symbol is one of retains
or retainsCap
Attributes
This symbol is one of retains
, retainsCap
, orretainsByName
This symbol is one of retains
, retainsCap
, orretainsByName
Attributes
The owner of the current level. Qualifying owners are
The owner of the current level. Qualifying owners are
- methods other than constructors and anonymous functions
- anonymous functions, provided they either define a local root of type caps.Cap, or they are the rhs of a val definition.
- classes, if they are not staticOwners
- root
Attributes
The outermost symbol owned by both sym
and other
. if none exists since the owning scopes of sym
and other
are not nested, invoke onConflict
to return a symbol.
The outermost symbol owned by both sym
and other
. if none exists since the owning scopes of sym
and other
are not nested, invoke onConflict
to return a symbol.
Attributes
The innermost symbol owning both sym
and other
.
The innermost symbol owning both sym
and other
.
Attributes
When applying sym
, would the result type be unboxed? This is the case if the result type contains a top-level reference to an enclosing class or method type parameter and the method does not allow root capture. If the type parameter is instantiated to a boxed type, that type would have to be unboxed in the method's result.
When applying sym
, would the result type be unboxed? This is the case if the result type contains a top-level reference to an enclosing class or method type parameter and the method does not allow root capture. If the type parameter is instantiated to a boxed type, that type would have to be unboxed in the method's result.
Attributes
If this is a unboxed capturing type with nonempty capture set, its boxed version. Or, if type is a TypeBounds of capturing types, the version where the bounds are boxed. The identity for all other types.
If this is a unboxed capturing type with nonempty capture set, its boxed version. Or, if type is a TypeBounds of capturing types, the version where the bounds are boxed. The identity for all other types.
Attributes
The capture set consisting of all top-level captures of tp
that appear under a box. Unlike for boxed
this also considers parents of capture types, unions and intersections, and type proxies other than abstract types.
The capture set consisting of all top-level captures of tp
that appear under a box. Unlike for boxed
this also considers parents of capture types, unions and intersections, and type proxies other than abstract types.
Attributes
Attributes
Drop @retains annotations everywhere
Drop @retains annotations everywhere
Attributes
If this type is a capturing type, the version with boxed statues as given by boxed
. If it is a TermRef of a capturing type, and the box status flips, widen to a capturing type that captures the TermRef.
If this type is a capturing type, the version with boxed statues as given by boxed
. If it is a TermRef of a capturing type, and the box status flips, widen to a capturing type that captures the TermRef.
Attributes
Is type known to be always pure by its class structure, so that adding a capture set to it would not make sense?
Is type known to be always pure by its class structure, so that adding a capture set to it would not make sense?
Attributes
Is the boxedCaptureSet of this type nonempty?
Is the boxedCaptureSet of this type nonempty?
Attributes
If x
is a capture ref, its maybe capability x?
, represented internally as x @maybeCapability
. x?
stands for a capability x
that might or might not be part of a capture set. We have {} <: {x?} <: {x}
. Maybe capabilities cannot be propagated between sets. If a <: b
and a
acquires x?
then x
is propagated to b
as a conservative approximation.
If x
is a capture ref, its maybe capability x?
, represented internally as x @maybeCapability
. x?
stands for a capability x
that might or might not be part of a capture set. We have {} <: {x?} <: {x}
. Maybe capabilities cannot be propagated between sets. If a <: b
and a
acquires x?
then x
is propagated to b
as a conservative approximation.
Maybe capabilities should only arise for capture sets that appear in invariant position in their surrounding type. They are similar to TypeBunds types, but restricted to capture sets. For instance,
Array[C^{x?}]
should be morally equivalent to
Array[_ >: C^{} <: C^{x}]
but it has fewer issues with type inference.
Attributes
If x
is a capture ref, its reach capability x*
, represented internally as x @reachCapability
. x*
stands for all capabilities reachable through x
". We have {x} <: {x*} <: 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 capture ref, its reach capability x*
, represented internally as x @reachCapability
. x*
stands for all capabilities reachable through x
". We have {x} <: {x*} <: 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.
Attributes
Map capturing type to their parents. Capturing types accessible via dealising are also stripped.
Map capturing type to their parents. Capturing types accessible via dealising are also stripped.
Attributes
If this is a unboxed capturing type with nonempty capture set, its boxed version. Or, if type is a TypeBounds of capturing types, the version where the bounds are boxed. The identity for all other types.
If this is a unboxed capturing type with nonempty capture set, its boxed version. Or, if type is a TypeBounds of capturing types, the version where the bounds are boxed. The identity for all other types.
Attributes
If ref
is a trackable capture ref, and tp
has only covariant occurrences of a universal capture set, replace all these occurrences by {ref*}
. This implements the new aspect of the (Var) rule, which can now be stated as follows:
If ref
is a trackable capture ref, and tp
has only covariant occurrences of a universal capture set, replace all these occurrences by {ref*}
. This implements the new aspect of the (Var) rule, which can now be stated as follows:
x: T in E
E |- x: T'
where T' is T with (1) the toplevel capture set replaced by {x}
and (2) all covariant occurrences of cap replaced by x*
, provided there are no occurrences in T
at other variances. (1) is standard, whereas (2) is new.
For (2), multiple-flipped covariant occurrences of cap won't be replaced. In other words,
- For xs: List[File^] ==> List[File^{xs*}], the cap is replaced;
- while f: [R] -> (op: File^ => R) -> R remains unchanged.
Without this restriction, the signature of functions like withFile:
(path: String) -> [R] -> (op: File^ => R) -> R
could be refined to
(path: String) -> [R] -> (op: File^{withFile*} => R) -> R
which is clearly unsound.
Why is this sound? Covariant occurrences of cap must represent capabilities that are reachable from x
, so they are included in the meaning of {x*}
. At the same time, encapsulation is still maintained since no covariant occurrences of cap are allowed in instance types of type variables.
Attributes
The arguments of a @retains, @retainsCap or @retainsByName annotation
The arguments of a @retains, @retainsCap or @retainsByName annotation
Attributes
Map tree with CaptureRef type to its type, throw IllegalCaptureRef otherwise
Map tree with CaptureRef type to its type, throw IllegalCaptureRef otherwise
Attributes
Convert a @retains or @retainsByName annotation tree to the capture set it represents. For efficience, the result is cached as an Attachment on the tree.
Convert a @retains or @retainsByName annotation tree to the capture set it represents. For efficience, the result is cached as an Attachment on the tree.