File tree 2 files changed +12
-2
lines changed
compiler/src/dotty/tools/dotc/cc
2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -285,6 +285,16 @@ extension (tp: Type)
285
285
case tp1 : TypeRef if ! tp1.symbol.is(Param ) => tp1.prefix.pathRoot
286
286
case tp1 => tp1
287
287
288
+ /** The first element of a path type, but stop at references extending
289
+ * SharableCapability
290
+ */
291
+ final def pathRootOrShared (using Context ): Type =
292
+ if tp.derivesFrom(defn.Caps_SharedCapability ) then tp
293
+ else tp.dealias match
294
+ case tp1 : TermRef if tp1.symbol.maybeOwner.isClass => tp1.prefix.pathRoot
295
+ case tp1 : TypeRef if ! tp1.symbol.is(Param ) => tp1.prefix.pathRoot
296
+ case tp1 => tp1
297
+
288
298
/** If this part starts with `C.this`, the class `C`.
289
299
* Otherwise, if it starts with a reference `r`, `r`'s owner.
290
300
* Otherwise NoSymbol.
Original file line number Diff line number Diff line change @@ -410,7 +410,7 @@ class SepChecker(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
410
410
val badParams = mutable.ListBuffer [Symbol ]()
411
411
def currentOwner = role.dclSym.orElse(ctx.owner)
412
412
for hiddenRef <- prune(refsToCheck, tpe, role) do
413
- val proot = hiddenRef.pathRoot
413
+ val proot = hiddenRef.pathRootOrShared
414
414
if ! proot.widen.derivesFrom(defn.Caps_SharedCapability ) then
415
415
proot match
416
416
case ref : TermRef =>
@@ -448,7 +448,7 @@ class SepChecker(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
448
448
role match
449
449
case _ : TypeRole .Argument | _ : TypeRole .Qualifier =>
450
450
for ref <- refsToCheck do
451
- if ! ref.derivesFrom(defn.Caps_SharedCapability ) then
451
+ if ! ref.pathRootOrShared. derivesFrom(defn.Caps_SharedCapability ) then
452
452
consumed.put(ref, pos)
453
453
case _ =>
454
454
end checkConsumedRefs
You can’t perform that action at this time.
0 commit comments