@@ -232,7 +232,9 @@ extension (tp: Type)
232
232
case tp @ ReachCapability (_) =>
233
233
tp.singletonCaptureSet
234
234
case ReadOnlyCapability (ref) =>
235
- ref.deepCaptureSet(includeTypevars).readOnly
235
+ val refDcs = ref.deepCaptureSet(includeTypevars)
236
+ if refDcs.isConst then CaptureSet (refDcs.elems.map(_.readOnly))
237
+ else refDcs // this case should not happen for correct programs
236
238
case tp : SingletonCaptureRef if tp.isTrackableRef =>
237
239
tp.reach.singletonCaptureSet
238
240
case _ =>
@@ -283,10 +285,20 @@ extension (tp: Type)
283
285
* are of the form this.C but their pathroot is still this.C, not this.
284
286
*/
285
287
final def pathRoot (using Context ): Type = tp.dealias match
286
- case tp1 : NamedType if tp1.symbol.maybeOwner.isClass && ! tp1.symbol.is( TypeParam ) =>
287
- tp1.prefix.pathRoot
288
+ case tp1 : TermRef if tp1.symbol.maybeOwner.isClass => tp1.prefix.pathRoot
289
+ case tp1 : TypeRef if ! tp1.symbol.is( Param ) => tp1.prefix.pathRoot
288
290
case tp1 => tp1
289
291
292
+ /** The first element of a path type, but stop at references extending
293
+ * SharedCapability.
294
+ */
295
+ final def pathRootOrShared (using Context ): Type =
296
+ if tp.derivesFromSharedCapability then tp
297
+ else tp.dealias match
298
+ case tp1 : TermRef if tp1.symbol.maybeOwner.isClass => tp1.prefix.pathRoot
299
+ case tp1 : TypeRef if ! tp1.symbol.is(Param ) => tp1.prefix.pathRoot
300
+ case tp1 => tp1
301
+
290
302
/** If this part starts with `C.this`, the class `C`.
291
303
* Otherwise, if it starts with a reference `r`, `r`'s owner.
292
304
* Otherwise NoSymbol.
0 commit comments