Skip to content

Commit 5e9e41c

Browse files
committed
Fix handling paths extending SharedCapabiolity
This partially reverts commit 7b3d3f4. It looks like this fixes the problems we had with CI timeouts as well.
1 parent 9066923 commit 5e9e41c

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

+2-12
Original file line numberDiff line numberDiff line change
@@ -285,20 +285,10 @@ extension (tp: Type)
285285
* are of the form this.C but their pathroot is still this.C, not this.
286286
*/
287287
final def pathRoot(using Context): Type = tp.dealias match
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+
case tp1: NamedType if tp1.symbol.maybeOwner.isClass && !tp1.symbol.is(TypeParam) =>
289+
tp1.prefix.pathRoot
290290
case tp1 => tp1
291291

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-
302292
/** If this part starts with `C.this`, the class `C`.
303293
* Otherwise, if it starts with a reference `r`, `r`'s owner.
304294
* Otherwise NoSymbol.

compiler/src/dotty/tools/dotc/cc/SepCheck.scala

+3-4
Original file line numberDiff line numberDiff line change
@@ -537,9 +537,8 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
537537
val badParams = mutable.ListBuffer[Symbol]()
538538
def currentOwner = role.dclSym.orElse(ctx.owner)
539539
for hiddenRef <- prune(refsToCheck, tpe, role) do
540-
val proot = hiddenRef.pathRootOrShared
541-
if !proot.widen.derivesFromSharedCapability then
542-
proot match
540+
if !hiddenRef.derivesFromSharedCapability then
541+
hiddenRef.pathRoot match
543542
case ref: TermRef =>
544543
val refSym = ref.symbol
545544
if currentOwner.enclosingMethodOrClass.isProperlyContainedIn(refSym.maybeOwner.enclosingMethodOrClass) then
@@ -575,7 +574,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
575574
role match
576575
case _: TypeRole.Argument | _: TypeRole.Qualifier =>
577576
for ref <- refsToCheck do
578-
if !ref.pathRootOrShared.derivesFromSharedCapability then
577+
if !ref.derivesFromSharedCapability then
579578
consumed.put(ref, pos)
580579
case _ =>
581580
end checkConsumedRefs

0 commit comments

Comments
 (0)