@@ -482,27 +482,30 @@ object Capabilities:
482
482
case info : OrType => viaInfo(info.tp1)(test) && viaInfo(info.tp2)(test)
483
483
case _ => false
484
484
485
+ def trySubpath (y : TermRef , trySamePrefix : Boolean = true ): Boolean =
486
+ y.prefix.match
487
+ case ypre : Capability =>
488
+ this .subsumes(ypre)
489
+ || trySamePrefix
490
+ && this .match
491
+ case x @ TermRef (xpre : Capability , _) if x.symbol == y.symbol =>
492
+ // To show `{x.f} <:< {y.f}`, it is important to prove `x` and `y`
493
+ // are equvalent, which means `x =:= y` in terms of subtyping,
494
+ // not just `{x} =:= {y}` in terms of subcapturing.
495
+ // It is possible to construct two singleton types `x` and `y`,
496
+ // which subsume each other, but are not equal references.
497
+ // See `tests/neg-custom-args/captures/path-prefix.scala` for example.
498
+ withMode(Mode .IgnoreCaptures ):
499
+ TypeComparer .isSameRef(xpre, ypre)
500
+ case _ =>
501
+ false
502
+ case _ => false
503
+
485
504
try (this eq y)
486
505
|| maxSubsumes(y, canAddHidden = ! vs.isOpen)
487
506
|| y.match
488
507
case y : TermRef =>
489
- y.prefix.match
490
- case ypre : Capability =>
491
- this .subsumes(ypre)
492
- || this .match
493
- case x @ TermRef (xpre : Capability , _) if x.symbol == y.symbol =>
494
- // To show `{x.f} <:< {y.f}`, it is important to prove `x` and `y`
495
- // are equvalent, which means `x =:= y` in terms of subtyping,
496
- // not just `{x} =:= {y}` in terms of subcapturing.
497
- // It is possible to construct two singleton types `x` and `y`,
498
- // which subsume each other, but are not equal references.
499
- // See `tests/neg-custom-args/captures/path-prefix.scala` for example.
500
- withMode(Mode .IgnoreCaptures ):
501
- TypeComparer .isSameRef(xpre, ypre)
502
- case _ =>
503
- false
504
- case _ => false
505
- || viaInfo(y.info)(subsumingRefs(this , _))
508
+ trySubpath(y) || viaInfo(y.info)(subsumingRefs(this , _))
506
509
case Maybe (y1) => this .stripMaybe.subsumes(y1)
507
510
case ReadOnly (y1) => this .stripReadOnly.subsumes(y1)
508
511
case y : TypeRef if y.derivesFrom(defn.Caps_CapSet ) =>
@@ -516,6 +519,12 @@ object Capabilities:
516
519
this .subsumes(hi)
517
520
case _ =>
518
521
y.captureSetOfInfo.elems.forall(this .subsumes)
522
+ case Reach (y1 : TermRef ) =>
523
+ def isClassFunctionParam : Boolean =
524
+ def isClassParam = y1.symbol.is(ParamAccessor )
525
+ def isFunctionType = defn.isFunctionType(y1.widenDealias)
526
+ isClassParam && isFunctionType
527
+ isClassFunctionParam && trySubpath(y1, trySamePrefix = false )
519
528
case _ => false
520
529
|| this .match
521
530
case Reach (x1) => x1.subsumes(y.stripReach)
0 commit comments