Skip to content

Commit 0811f44

Browse files
oderskyhamzaremmal
authored andcommitted
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 81f9c24 commit 0811f44

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

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

Lines changed: 2 additions & 12 deletions
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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,8 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
551551
val badParams = mutable.ListBuffer[Symbol]()
552552
def currentOwner = role.dclSym.orElse(ctx.owner)
553553
for hiddenRef <- prune(refsToCheck, tpe, role) do
554-
val proot = hiddenRef.pathRootOrShared
555-
if !proot.widen.derivesFromSharedCapability then
556-
proot match
554+
if !hiddenRef.derivesFromSharedCapability then
555+
hiddenRef.pathRoot match
557556
case ref: TermRef =>
558557
val refSym = ref.symbol
559558
if currentOwner.enclosingMethodOrClass.isProperlyContainedIn(refSym.maybeOwner.enclosingMethodOrClass) then
@@ -589,7 +588,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
589588
role match
590589
case _: TypeRole.Argument | _: TypeRole.Qualifier =>
591590
for ref <- refsToCheck do
592-
if !ref.pathRootOrShared.derivesFromSharedCapability then
591+
if !ref.derivesFromSharedCapability then
593592
consumed.put(ref, pos)
594593
case _ =>
595594
end checkConsumedRefs

0 commit comments

Comments
 (0)