root
A module defining three kinds of root capabilities
cap
of kindGlobal
: This is the global root capability. Among others it is used in the types of formal parameters, in type bounds, and in self types.cap
does not subsume other capabilities, except in arguments ofwithCapAsRoot
calls.- Instances of Fresh(hidden), of kind Fresh. These do subsume other capabilties in scope. They track with hidden sets which other capabilities were subsumed. Hidden sets are inspected by separation checking.
- Instances of Result(binder), of kind Result. These are existentials associated with the result types of dependent methods. They don't subsume other capabilties.
Representation:
cap
is just the TermRefscala.caps.cap
defined in thecaps
moduleFresh
andResult
instances are annotated types ofscala.caps.cap
with a specialroot.Annot
annotation. The symbol of the annotation isannotation.internal.rootCapability
. The annotation carries a kind, which provides a hidden set for Fresh instances and a binder method type for Result instances.
Setup:
In the setup phase, cap
instances in the result of a dependent function type or method type such as (x: T): C^{cap}
are converted to Result(binder)
instances, where binder
refers to the method type. Most other cap instances are mapped to Fresh instances instead. For example the cap
in the result of T => C^{cap}
is mapped to a Fresh instance.
If one needs to use a dependent function type yet one still want to map cap
to a fresh instance instead an existential root, one can achieve that by the use of a type alias. For instance, the following type creates an existential for ^
:
(x: A) => (C^{x}, D^)
By contrast, this variant creates a fresh instance instead:
type F[X] = (x: A) => (C^{x}, X)
F[D^]
The trick is that the argument D^ is mapped to D^{fresh} before the F
alias is expanded.
Attributes
- Graph
-
- Supertypes
- Self type
-
root.type