File tree Expand file tree Collapse file tree 2 files changed +5
-16
lines changed
compiler/src/dotty/tools/dotc/cc Expand file tree Collapse file tree 2 files changed +5
-16
lines changed Original file line number Diff line number Diff line change @@ -281,20 +281,10 @@ extension (tp: Type)
281281
282282 /** The first element of this path type */
283283 final def pathRoot (using Context ): Type = tp.dealias match
284- case tp1 : TermRef if tp1.symbol.maybeOwner.isClass => tp1.prefix.pathRoot
285- case tp1 : TypeRef if ! tp1.symbol.is( Param ) => tp1.prefix.pathRoot
284+ case tp1 : NamedType if tp1.symbol.maybeOwner.isClass && ! tp1.symbol.is( TypeParam ) =>
285+ tp1.prefix.pathRoot
286286 case tp1 => tp1
287287
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-
298288 /** If this part starts with `C.this`, the class `C`.
299289 * Otherwise, if it starts with a reference `r`, `r`'s owner.
300290 * Otherwise NoSymbol.
Original file line number Diff line number Diff line change @@ -410,9 +410,8 @@ class SepChecker(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
410410 val badParams = mutable.ListBuffer [Symbol ]()
411411 def currentOwner = role.dclSym.orElse(ctx.owner)
412412 for hiddenRef <- prune(refsToCheck, tpe, role) do
413- val proot = hiddenRef.pathRootOrShared
414- if ! proot.widen.derivesFrom(defn.Caps_SharedCapability ) then
415- proot match
413+ if ! hiddenRef.derivesFrom(defn.Caps_SharedCapability ) then
414+ hiddenRef.pathRoot match
416415 case ref : TermRef =>
417416 val refSym = ref.symbol
418417 if currentOwner.enclosingMethodOrClass.isProperlyContainedIn(refSym.maybeOwner.enclosingMethodOrClass) then
@@ -448,7 +447,7 @@ class SepChecker(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
448447 role match
449448 case _ : TypeRole .Argument | _ : TypeRole .Qualifier =>
450449 for ref <- refsToCheck do
451- if ! ref.pathRootOrShared. derivesFrom(defn.Caps_SharedCapability ) then
450+ if ! ref.derivesFrom(defn.Caps_SharedCapability ) then
452451 consumed.put(ref, pos)
453452 case _ =>
454453 end checkConsumedRefs
You can’t perform that action at this time.
0 commit comments