@@ -166,6 +166,9 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
166
166
try op finally frozenGadt = savedFrozenGadt
167
167
}
168
168
169
+ private inline def inFrozenGadtAndConstraint [T ](inline op : T ): T =
170
+ inFrozenGadtIf(true )(inFrozenConstraint(op))
171
+
169
172
protected def isSubType (tp1 : Type , tp2 : Type , a : ApproxState ): Boolean = {
170
173
val savedApprox = approx
171
174
val savedLeftRoot = leftRoot
@@ -431,25 +434,18 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
431
434
case Some (b) => return b
432
435
case None =>
433
436
434
- /** `recur` shouldn't normally be used with approximated types, according to its
435
- * documentation. In the specific examples where this function is
436
- * called, it is sound to do so as long as we freeze GADTs.
437
- */
438
- def recurInFrozenGadt (tp1 : Type , tp2 : Type ) =
439
- inFrozenGadt { recur(tp1, tp2) }
440
-
441
437
def widenOK =
442
438
(tp2.widenSingletons eq tp2)
443
439
&& (tp1.widenSingletons ne tp1)
444
- && inFrozenConstraint(recurInFrozenGadt (tp1.widenSingletons, tp2))
440
+ && inFrozenGadtAndConstraint(recur (tp1.widenSingletons, tp2))
445
441
446
442
def joinOK = tp2.dealiasKeepRefiningAnnots match {
447
443
case tp2 : AppliedType if ! tp2.tycon.typeSymbol.isClass =>
448
444
// If we apply the default algorithm for `A[X] | B[Y] <: C[Z]` where `C` is a
449
445
// type parameter, we will instantiate `C` to `A` and then fail when comparing
450
446
// with `B[Y]`. To do the right thing, we need to instantiate `C` to the
451
447
// common superclass of `A` and `B`.
452
- recurInFrozenGadt( tp1.join, tp2)
448
+ inFrozenGadtAndConstraint(recur( tp1.join, tp2) )
453
449
case _ =>
454
450
false
455
451
}
@@ -476,7 +472,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
476
472
widenOK
477
473
|| joinOK
478
474
|| (tp1.isSoft || constrainRHSVars(tp2)) && recur(tp11, tp2) && recur(tp12, tp2)
479
- || containsAnd(tp1) && recurInFrozenGadt( tp1.join, tp2)
475
+ || containsAnd(tp1) && inFrozenGadt(recur( tp1.join, tp2) )
480
476
case tp1 : MatchType =>
481
477
val reduced = tp1.reduced
482
478
if (reduced.exists) recur(reduced, tp2) else thirdTry
0 commit comments