@@ -39,8 +39,7 @@ import collection.immutable
3939 * | +-- SetCapability -----+-- TypeRef
4040 * | +-- TypeParamRef
4141 * |
42- * +-- DerivedCapability -+-- Reach
43- * +-- Only
42+ * +-- DerivedCapability -+-- Only
4443 * +-- ReadOnly
4544 * +-- Maybe
4645 *
@@ -106,41 +105,23 @@ object Capabilities:
106105
107106 /** The readonly capability `x.rd`. We have {x.rd} <: {x}.
108107 *
109- * Read-only capabilities cannot wrap maybe capabilities
110- * but they can wrap reach capabilities. We have
111- * (x?).readOnly = (x.rd)?
108+ * Read-only capabilities cannot wrap maybe capabilities.
112109 */
113- case class ReadOnly (underlying : CoreCapability | RootCapability | Reach | Restricted )
110+ case class ReadOnly (underlying : CoreCapability | RootCapability | Restricted )
114111 extends DerivedCapability :
115112 def newLikeThis (c : Capability ) = ReadOnly (c.asInstanceOf )
116113
117114 /** The restricted capability `x.only[C]`. We have {x.only[C]} <: {x}.
118115 *
119- * Restricted capabilities cannot wrap maybe capabilities or read-only capabilities
120- * but they can wrap reach capabilities. We have
116+ * Restricted capabilities cannot wrap maybe capabilities or read-only capabilities.
117+ * We have
121118 * (x?).restrict[T] = (x.restrict[T])?
122119 * (x.rd).restrict[T] = (x.restrict[T]).rd
123120 */
124- case class Restricted (underlying : CoreCapability | RootCapability | Reach , cls : ClassSymbol )
121+ case class Restricted (underlying : CoreCapability | RootCapability , cls : ClassSymbol )
125122 extends DerivedCapability :
126123 def newLikeThis (c : Capability ) = Restricted (c.asInstanceOf , cls)
127124
128- /** If `x` is a capability, its reach capability `x*`. `x*` stands for all
129- * capabilities reachable through `x`.
130- * We have `{x} <: {x*} <: dcs(x)}` where the deep capture set `dcs(x)` of `x`
131- * is the union of all capture sets that appear in covariant position in the
132- * type of `x`. If `x` and `y` are different variables then `{x*}` and `{y*}`
133- * are unrelated.
134- *
135- * Reach capabilities cannot wrap read-only capabilities or maybe capabilities.
136- * We have
137- * (x?).reach = (x.reach)?
138- * (x.rd).reach = (x.reach).rd
139- * (x.only[T]).reach = (x*).only[T]
140- */
141- case class Reach (underlying : ObjectCapability ) extends DerivedCapability :
142- def newLikeThis (c : Capability ) = Reach (c.asInstanceOf )
143-
144125 /** A class for the global root capabilities referenced as `caps.any` and `caps.fresh`.
145126 * They do not subsume other capabilities, except in arguments of `withCapAsRoot` calls.
146127 */
@@ -149,7 +130,6 @@ object Capabilities:
149130 override val maybe = Maybe (this )
150131 override val readOnly = ReadOnly (this )
151132 override def restrict (cls : ClassSymbol )(using Context ) = Restricted (this , cls)
152- override def reach = unsupported(" caps.any.reach" )
153133 override def singletonCaptureSet (using Context ) = CaptureSet .universal
154134 override def captureSetOfInfo (using Context ) = singletonCaptureSet
155135 override def cached [C <: DerivedCapability ](newRef : C ): C = unsupported(" cached" )
@@ -334,7 +314,7 @@ object Capabilities:
334314 end ResultCap
335315
336316 /** A trait for references in CaptureSets. These can be NamedTypes, ThisTypes or ParamRefs,
337- * as well as three kinds of AnnotatedTypes representing readOnly, reach , and maybe capabilities.
317+ * as well as three kinds of AnnotatedTypes representing readOnly, only , and maybe capabilities.
338318 * If there are several annotations they come with an order:
339319 * `*` first, `.only` next, `.rd` next, `?` last.
340320 */
@@ -371,7 +351,7 @@ object Capabilities:
371351 def readOnly : ReadOnly | Maybe = this match
372352 case Maybe (ref1) => Maybe (ref1.readOnly)
373353 case self : ReadOnly => self
374- case self : (CoreCapability | RootCapability | Reach | Restricted ) => cached(ReadOnly (self))
354+ case self : (CoreCapability | RootCapability | Restricted ) => cached(ReadOnly (self))
375355
376356 def restrict (cls : ClassSymbol )(using Context ): Restricted | ReadOnly | Maybe = this match
377357 case Maybe (ref1) => Maybe (ref1.restrict(cls))
@@ -380,14 +360,7 @@ object Capabilities:
380360 val combinedCls = leastClassifier(prevCls, cls)
381361 if combinedCls == prevCls then self
382362 else cached(Restricted (ref1, combinedCls))
383- case self : (CoreCapability | RootCapability | Reach ) => cached(Restricted (self, cls))
384-
385- def reach : Reach | Restricted | ReadOnly | Maybe = this match
386- case Maybe (ref1) => Maybe (ref1.reach)
387- case ReadOnly (ref1) => ReadOnly (ref1.reach.asInstanceOf [Reach | Restricted ])
388- case Restricted (ref1, cls) => Restricted (ref1.reach.asInstanceOf [Reach ], cls)
389- case self : Reach => self
390- case self : ObjectCapability => cached(Reach (self))
363+ case self : (CoreCapability | RootCapability ) => cached(Restricted (self, cls))
391364
392365 /** Is this a maybe reference of the form `x?`? */
393366 final def isMaybe (using Context ): Boolean = this ne stripMaybe
@@ -411,11 +384,6 @@ object Capabilities:
411384 case self : ResultCap => self.origin.classifier
412385 case _ => NoSymbol
413386
414- /** Is this a reach reference of the form `x*` or a readOnly or maybe variant
415- * of a reach reference?
416- */
417- final def isReach (using Context ): Boolean = this ne stripReach
418-
419387 final def stripMaybe (using Context ): Capability = this match
420388 case Maybe (ref1) => ref1
421389 case _ => this
@@ -435,13 +403,6 @@ object Capabilities:
435403 final def stripRestricted (using Context ): Capability =
436404 stripRestricted(defn.NothingClass )
437405
438- final def stripReach (using Context ): Capability = this match
439- case Reach (ref1) => ref1
440- case ReadOnly (ref1) => ref1.stripReach.readOnly
441- case Restricted (ref1, cls) => ref1.stripReach.restrict(cls)
442- case Maybe (ref1) => ref1.stripReach.maybe
443- case _ => this
444-
445406 /** Is this reference a root capability or a derived version of one?
446407 * These capabilities have themselves as their captureSetOfInfo.
447408 */
@@ -594,7 +555,6 @@ object Capabilities:
594555
595556 /** Tests whether the capability derives from capability class `cls`. */
596557 def derivesFromCapTrait (cls : ClassSymbol )(using Context ): Boolean = this match
597- case Reach (ref1) => ref1.widen.derivesFromCapTraitDeeply(cls)
598558 case self : DerivedCapability => self.underlying.derivesFromCapTrait(cls)
599559 case self : CoreCapability => self.superType.derivesFromCapTrait(cls)
600560 case _ => false
@@ -660,8 +620,6 @@ object Capabilities:
660620 ref1.transClassifiers
661621 case Maybe (ref1) =>
662622 ref1.transClassifiers
663- case Reach (_) =>
664- captureSetOfInfo.transClassifiers
665623 case self : CoreCapability =>
666624 if self.derivesFromCapability then toClassifiers(self.inheritedClassifier)
667625 else captureSetOfInfo.transClassifiers
@@ -685,8 +643,6 @@ object Capabilities:
685643 ref1.tryClassifyAs(cls)
686644 case Maybe (ref1) =>
687645 ref1.tryClassifyAs(cls)
688- case Reach (_) =>
689- captureSetOfInfo.tryClassifyAs(cls)
690646 case self : CoreCapability =>
691647 if self.derivesFromCapability then self.derivesFrom(cls)
692648 else captureSetOfInfo.tryClassifyAs(cls)
@@ -784,7 +740,6 @@ object Capabilities:
784740 this .subsumes(y.cls.sourceModule.termRef)
785741 case _ => false
786742 || this .match
787- case Reach (x1) => x1.subsumes(y.stripReach)
788743 case Restricted (x1, cls) => y.isKnownClassifiedAs(cls) && x1.subsumes(y)
789744 case x : TermRef => viaInfo(x.info)(subsumingRefs(_, y))
790745 case x : TypeRef if assumedContainsOf(x).contains(y) => true
@@ -886,10 +841,6 @@ object Capabilities:
886841 || y.match
887842 case y @ TermRef (ypre : Capability , _) =>
888843 recur(x, ypre)
889- case Reach (y1) =>
890- x match
891- case Reach (x1) => recur(x1, y1)
892- case _ => false
893844 case Maybe (y1) =>
894845 x match
895846 case Maybe (x1) => recur(x1, y1)
@@ -947,7 +898,6 @@ object Capabilities:
947898 c match
948899 case _ : ReadOnly => ReadOnlyCapability (c1)
949900 case Restricted (_, cls) => OnlyCapability (c1, cls)
950- case _ : Reach => ReachCapability (c1)
951901 case _ : Maybe => MaybeCapability (c1)
952902 case _ => c1
953903
@@ -1117,9 +1067,9 @@ object Capabilities:
11171067 case _ =>
11181068 mapFollowingAliases(t)
11191069
1120- override def mapCapability (c : Capability , deep : Boolean ): Capability = c match
1070+ override def mapCapability (c : Capability ): Capability = c match
11211071 case GlobalAny => LocalCap (origin)
1122- case _ => super .mapCapability(c, deep )
1072+ case _ => super .mapCapability(c)
11231073
11241074 override def fuse (next : BiTypeMap )(using Context ) = next match
11251075 case next : Inverse => assert(false ); Some (IdentityTypeMap )
@@ -1132,9 +1082,9 @@ object Capabilities:
11321082 case t @ CapturingType (_, refs) => mapOver(t)
11331083 case _ => mapFollowingAliases(t)
11341084
1135- override def mapCapability (c : Capability , deep : Boolean ): Capability = c match
1085+ override def mapCapability (c : Capability ): Capability = c match
11361086 case _ : LocalCap => GlobalAny
1137- case _ => super .mapCapability(c, deep )
1087+ case _ => super .mapCapability(c)
11381088
11391089 def inverse = thisMap
11401090 override def toString = thisMap.toString + " .inverse"
@@ -1181,7 +1131,7 @@ object Capabilities:
11811131 if t.binder == this .binder then paramSyms(t.paramNum).termRef else t
11821132 case _ => mapOver(t)
11831133
1184- override def mapCapability (c : Capability , deep : Boolean ): Capability = c match
1134+ override def mapCapability (c : Capability ): Capability = c match
11851135 case r : ResultCap if r.binder == this .binder =>
11861136 resultToAny.get(r) match
11871137 case Some (f) => f
@@ -1191,7 +1141,7 @@ object Capabilities:
11911141 anyToResult(f) = r
11921142 f
11931143 case _ =>
1194- super .mapCapability(c, deep )
1144+ super .mapCapability(c)
11951145
11961146 class Inverse extends BiTypeMap :
11971147 def apply (t : Type ): Type =
@@ -1201,7 +1151,7 @@ object Capabilities:
12011151 binder.paramRefs(paramSyms.indexOf(t.symbol))
12021152 case _ => mapOver(t)
12031153
1204- override def mapCapability (c : Capability , deep : Boolean ): Capability = c match
1154+ override def mapCapability (c : Capability ): Capability = c match
12051155 case f : LocalCap if f.owner == sym =>
12061156 anyToResult.get(f) match
12071157 case Some (r) => r
@@ -1210,7 +1160,7 @@ object Capabilities:
12101160 resultToAny(r) = f
12111161 anyToResult(f) = r
12121162 r
1213- case _ => super .mapCapability(c, deep )
1163+ case _ => super .mapCapability(c)
12141164
12151165 def inverse = thisMap
12161166 override def toString = thisMap.toString + " .inverse"
@@ -1239,7 +1189,7 @@ object Capabilities:
12391189 case _ =>
12401190 mapOver(t)
12411191
1242- override def mapCapability (c : Capability , deep : Boolean ) = c match
1192+ override def mapCapability (c : Capability ) = c match
12431193 case c @ ResultCap (binder) =>
12441194 if localBinders.contains(binder) then c // keep bound references
12451195 else
@@ -1249,7 +1199,7 @@ object Capabilities:
12491199 lc.hiddenSet.markSolved(provisional = false )
12501200 lc
12511201 seen.getOrElseUpdate(c, localCapSkolem) // map free references to LocalCap
1252- case _ => super .mapCapability(c, deep )
1202+ case _ => super .mapCapability(c)
12531203 end subst
12541204
12551205 subst(tp)
@@ -1268,7 +1218,7 @@ object Capabilities:
12681218
12691219 def apply (t : Type ) = mapOver(t)
12701220
1271- override def mapCapability (c : Capability , deep : Boolean ) = c match
1221+ override def mapCapability (c : Capability ) = c match
12721222 case c : LocalCap =>
12731223 if variance >= 0 then
12741224 if sym.exists && ! c.ccOwner.isContainedIn(sym) then
@@ -1282,15 +1232,15 @@ object Capabilities:
12821232 case GlobalFresh =>
12831233 ResultCap (mt) // if variance <= 0 we leave the fresh to be flagged later
12841234 case _ =>
1285- super .mapCapability(c, deep )
1235+ super .mapCapability(c)
12861236
12871237 // .showing(i"mapcap $t = $result")
12881238 override def toString = " toVar"
12891239
12901240 object inverse extends BiTypeMap :
12911241 def apply (t : Type ) = mapOver(t)
12921242
1293- override def mapCapability (c : Capability , deep : Boolean ) = c match
1243+ override def mapCapability (c : Capability ) = c match
12941244 case c @ ResultCap (`mt`) =>
12951245 val primary = c.primaryResultCap
12961246 primary.origin match
@@ -1301,7 +1251,7 @@ object Capabilities:
13011251 case origin : LocalCap =>
13021252 origin
13031253 case _ =>
1304- super .mapCapability(c, deep )
1254+ super .mapCapability(c)
13051255
13061256 def inverse = ToResult .this
13071257 override def toString = " toVar.inverse"
@@ -1313,12 +1263,12 @@ object Capabilities:
13131263 */
13141264 class RetractResult (rcs : SimpleIdentitySet [ResultCap ])(using Context ) extends TypeMap :
13151265 def apply (t : Type ) = mapOver(t)
1316- override def mapCapability (c : Capability , deep : Boolean ) = c match
1266+ override def mapCapability (c : Capability ) = c match
13171267 case c : ResultCap if rcs.exists(_.primaryResultCap == c.primaryResultCap) =>
13181268 c.primaryResultCap.origin match
13191269 case origin : LocalCap => origin
13201270 case _ => c
1321- case _ => super .mapCapability(c, deep )
1271+ case _ => super .mapCapability(c)
13221272
13231273 /** Replace all occurrences of `caps.any` or LocalCap in parts of this type by an existentially bound
13241274 * variable bound by `mt`. Stop at function or method types since these have been mapped before.
0 commit comments