You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/_docs/reference/experimental/cc.md
+10-3
Original file line number
Diff line number
Diff line change
@@ -737,15 +737,22 @@ The type variable `cap X` (with `cap` being a soft modifier) can be instantiated
737
737
we see a variable `listeners` that has as type a `Set` of `Listeners` capturing `X`. The `register` method takes a listener of this type
738
738
and assigns it to the variable.
739
739
740
-
Capture-set variables `cap X` are represented as regular type variables within the special interval
741
-
`>: CapSet <: CapSet^`. For instance, `Source` could be equivalently
740
+
Capture-set variables `cap X` without user-annotated bounds by default range over the interval `>: {} <: {caps.cap}` which is the universe of capture sets instead of regular types.
741
+
742
+
Under the hood, such capture-set variables are represented as regular type variables within the special interval
743
+
`>: CapSet <: CapSet^`.
744
+
For instance, `Source` from above could be equivalently
742
745
defined as follows:
743
746
```scala
744
747
classSource[X>:CapSet<:CapSet^]:
745
748
...
746
749
```
747
750
`CapSet` is a sealed trait in the `caps` object. It cannot be instantiated or inherited, so its only
748
-
purpose is to identify capture-set type variables and types. This representation based on `CapSet` is subject to change and
751
+
purpose is to identify type variables which are capture sets. In non-capture-checked
752
+
usage contexts, the type system will treat `CapSet^{a}` and `CapSet^{a,b}` as the type `CapSet`, whereas
753
+
with capture checking enabled, it will take the annotated capture sets into account,
754
+
so that `CapSet^{a}` and `CapSet^{a,b}` are distinct.
755
+
This representation based on `CapSet` is subject to change and
749
756
its direct use is discouraged.
750
757
751
758
Capture-set variables can be inferred like regular type variables. When they should be instantiated
0 commit comments