Skip to content

Commit 82c74ff

Browse files
committed
Add Stateful and Separate to caps package
Also: drop redundant statement in captureSetImpliedByFields
1 parent 1786511 commit 82c74ff

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,6 @@ class CheckCaptures extends Recheck, SymTransformer:
980980
def impliedClassifiers(cls: Symbol): List[ClassSymbol] = cls match
981981
case cls: ClassSymbol =>
982982
var fieldClassifiers = knownFields(cls).flatMap(classifiersOfFreshInType)
983-
if cls.typeRef.isMutableType then
984-
fieldClassifiers = cls.classifier :: fieldClassifiers
985983
val parentClassifiers =
986984
cls.parentSyms.map(impliedClassifiers).filter(_.nonEmpty)
987985
if fieldClassifiers.isEmpty && parentClassifiers.isEmpty

library/src/scala/caps/package.scala

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,32 @@ type Exclusive = ExclusiveCapability
7878
*/
7979
trait Control extends SharedCapability, Classifier
8080

81-
/** Marker trait for classes with methods that require an exclusive reference. */
81+
/** Marker trait for classes that can consult and change the global program state.
82+
* These classes typically contain mutable variables and/or update methods.
83+
*/
8284
@experimental
83-
trait Mutable extends ExclusiveCapability
85+
trait Stateful extends ExclusiveCapability
8486

85-
/** Marker trait for classes with reader methods, typically extended by Mutable classes */
87+
/** Marker trait for classes that produce fresh capabilities with their values. If a value of a type
88+
* extending Separate is created, a fresh `cap` is automatically added to the value's capture set.
89+
*/
8690
@experimental
87-
@deprecated
88-
trait Read extends Mutable
91+
trait Separate extends ExclusiveCapability
8992

90-
/** Marker trait for classes that are not subject to scoping restrictions
91-
* of captured capabilities.
93+
/** Marker trait for classes that are not subject to scoping restrictions of captured capabilities.
9294
*/
9395
@experimental
9496
trait Unscoped extends ExclusiveCapability, Classifier
9597

98+
@experimental
99+
trait Mutable extends Stateful, Separate //, Unscoped
100+
101+
/** Marker trait for classes with reader methods, typically extended by Mutable classes */
102+
@experimental
103+
@deprecated
104+
trait Read extends Mutable
105+
106+
96107
/** Carrier trait for capture set type parameters */
97108
@experimental
98109
trait CapSet extends Any

0 commit comments

Comments
 (0)