@@ -546,7 +546,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
546
546
case tp1 @ CapturingType (parent1, refs1) =>
547
547
def compareCapturing =
548
548
if tp2.isAny then true
549
- else if subCaptures(refs1, tp2.captureSet) && sameBoxed(tp1 , tp2, refs1 )
549
+ else if compareCaptures(tp1, refs1 , tp2, tp2.captureSet )
550
550
|| ! ctx.mode.is(Mode .CheckBoundsOrSelfType ) && tp1.isAlwaysPure
551
551
then
552
552
val tp2a =
@@ -673,12 +673,12 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
673
673
&& isSubInfo(info1.resultType, info2.resultType.subst(info2, info1))
674
674
case (info1 @ CapturingType (parent1, refs1), info2 : Type )
675
675
if info2.stripCapturing.isInstanceOf [MethodOrPoly ] =>
676
- subCaptures(refs1, info2.captureSet) && sameBoxed(info1 , info2, refs1 )
676
+ compareCaptures(info1, refs1 , info2, info2.captureSet )
677
677
&& isSubInfo(parent1, info2)
678
678
case (info1 : Type , CapturingType (parent2, refs2))
679
679
if info1.stripCapturing.isInstanceOf [MethodOrPoly ] =>
680
680
val refs1 = info1.captureSet
681
- (refs1.isAlwaysEmpty || subCaptures(refs1, refs2)) && sameBoxed(info1 , info2, refs1 )
681
+ (refs1.isAlwaysEmpty || compareCaptures(info1, refs1 , info2, refs2) )
682
682
&& isSubInfo(info1, parent2)
683
683
case _ =>
684
684
isSubType(info1, info2)
@@ -877,8 +877,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
877
877
case _ =>
878
878
false
879
879
singletonOK
880
- || subCaptures(refs1, refs2)
881
- && sameBoxed(tp1, tp2, refs1)
880
+ || compareCaptures(tp1, refs1, tp2, refs2)
882
881
&& (recur(tp1.widen.stripCapturing, parent2)
883
882
|| tp1.isInstanceOf [SingletonType ] && recur(tp1, parent2)
884
883
// this alternative is needed in case the right hand side is a
@@ -2891,13 +2890,16 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
2891
2890
println(i " fail while subCaptures $refs1 <:< $refs2" )
2892
2891
throw ex
2893
2892
2894
- /** Is the boxing status of tp1 and tp2 the same, or alternatively, is
2895
- * the capture sets `refs1` of `tp1` a subcapture of the empty set?
2896
- * In the latter case, boxing status does not matter.
2893
+ /**
2894
+ * - Compare capture sets using subCaptures.
2895
+ * - Test whether the boxing status of tp1 and tp2 the same, or alternatively,
2896
+ * whether the capture set `refs1` of `tp1` is subcapture of the empty set?
2897
+ * In the latter case, boxing status does not matter.
2897
2898
*/
2898
- protected def sameBoxed (tp1 : Type , tp2 : Type , refs1 : CaptureSet )(using Context ): Boolean =
2899
- (tp1.isBoxedCapturing == tp2.isBoxedCapturing)
2900
- || refs1.subCaptures(CaptureSet .empty, makeVarState())
2899
+ protected def compareCaptures (tp1 : Type , refs1 : CaptureSet , tp2 : Type , refs2 : CaptureSet ): Boolean =
2900
+ subCaptures(refs1, refs2)
2901
+ && (tp1.isBoxedCapturing == tp2.isBoxedCapturing)
2902
+ || refs1.subCaptures(CaptureSet .empty, makeVarState())
2901
2903
2902
2904
protected def logUndoAction (action : () => Unit ) =
2903
2905
undoLog += action
0 commit comments