File tree Expand file tree Collapse file tree 2 files changed +26
-2
lines changed
compiler/src/dotty/tools/dotc/cc
tests/pos-custom-args/captures Expand file tree Collapse file tree 2 files changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -434,10 +434,12 @@ object Capabilities:
434434
435435 /** An exclusive capability is a capability that derives
436436 * indirectly from a maximal capability without going through
437- * a read-only capability first.
437+ * a read-only capability or a capability classified as SharedCapability first.
438438 */
439439 final def isExclusive (using Context ): Boolean =
440- ! isReadOnly && (isTerminalCapability || captureSetOfInfo.isExclusive)
440+ ! isReadOnly
441+ && ! classifier.isSubClass(defn.Caps_SharedCapability )
442+ && (isTerminalCapability || captureSetOfInfo.isExclusive)
441443
442444 /** Similar to isExlusive, but also includes capabilties with capture
443445 * set variables in their info whose status is still open.
Original file line number Diff line number Diff line change 1+ import language .experimental .captureChecking
2+ import language .experimental .separationChecking
3+ import caps .*
4+ class Logger extends SharedCapability :
5+ def log (msg : String ): Unit = ()
6+ class TracedRef (logger : Logger ^ {cap.only[SharedCapability ]}) extends Mutable :
7+ private var _data : Int = 0
8+ update def set (newValue : Int ): Unit =
9+ logger.log(" set" )
10+ _data = newValue
11+ def get : Int =
12+ logger.log(" get" ) // error, but should it be allowed?
13+ _data
14+
15+ class TracedRef2 (logger : Logger ) extends Mutable :
16+ private var _data : Int = 0
17+ update def set (newValue : Int ): Unit =
18+ logger.log(" set" )
19+ _data = newValue
20+ def get : Int =
21+ logger.log(" get" ) // error, but should it be allowed?
22+ _data
You can’t perform that action at this time.
0 commit comments