File tree Expand file tree Collapse file tree 2 files changed +110
-91
lines changed
compiler/src/dotty/tools/dotc/cc Expand file tree Collapse file tree 2 files changed +110
-91
lines changed Original file line number Diff line number Diff line change @@ -548,14 +548,19 @@ object Capabilities:
548
548
computed
549
549
550
550
/** The elements hidden by this capability, if this is a FreshCap
551
- * or a derived version of one. Read-only status is transferred from
552
- * the capability to its hidden set. TODO Should classifiers also be
553
- * transferred?
551
+ * or a derived version of one. Read-only status and restrictions
552
+ * are transferred from the capability to its hidden set.
554
553
*/
555
- def hiddenElems (using Context ): Refs = this .stripRestricted.stripReadOnly match
556
- case self : FreshCap =>
557
- val hidden = self.hiddenSet.elems
558
- if isReadOnly then hidden.map(_.readOnly) else hidden
554
+ def hiddenSet (using Context ): Refs = computeHiddenSet(identity)
555
+
556
+ /** Compute hidden set of this capability.
557
+ * Restrictions and read-only status transfer from the capability to its
558
+ * hidden set.
559
+ */
560
+ def computeHiddenSet (f : Refs => Refs )(using Context ): Refs = this match
561
+ case self : FreshCap => f(self.hiddenSet.elems)
562
+ case Restricted (elem1, cls) => elem1.computeHiddenSet(f).map(_.restrict(cls))
563
+ case ReadOnly (elem1) => elem1.computeHiddenSet(f).map(_.readOnly)
559
564
case _ => emptyRefs
560
565
561
566
/** The transitive classifiers of this capability. */
You can’t perform that action at this time.
0 commit comments