@@ -23,7 +23,7 @@ import typer.ProtoTypes.constrained
2323import typer .Applications .productSelectorTypes
2424import reporting .trace
2525import annotation .constructorOnly
26- import cc .{CapturingType , derivedCapturingType , CaptureSet , stripCapturing , isBoxedCapturing , boxedUnlessFun }
26+ import cc .{CapturingType , derivedCapturingType , CaptureSet , stripCapturing , isBoxedCapturing , boxed , boxedUnlessFun , boxedIfTypeParam }
2727
2828/** Provides methods to compare types.
2929 */
@@ -426,7 +426,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
426426 case tp2 : TypeParamRef => constraint.isLess(tp1, tp2)
427427 case _ => false
428428 } ||
429- isSubTypeWhenFrozen(bounds(tp1).hi, tp2) || {
429+ isSubTypeWhenFrozen(bounds(tp1).hi.boxed , tp2) || {
430430 if (canConstrain(tp1) && ! approx.high)
431431 addConstraint(tp1, tp2, fromBelow = false ) && flagNothingBound
432432 else thirdTry
@@ -547,7 +547,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
547547 || narrowGADTBounds(tp2, tp1, approx, isUpper = false ))
548548 && (isBottom(tp1) || GADTusage (tp2.symbol))
549549
550- isSubApproxHi(tp1, info2.lo) && (trustBounds || isSubApproxHi(tp1, info2.hi))
550+ isSubApproxHi(tp1, info2.lo.boxedIfTypeParam(tp2.symbol) ) && (trustBounds || isSubApproxHi(tp1, info2.hi))
551551 || compareGADT
552552 || tryLiftedToThis2
553553 || fourthTry
@@ -586,7 +586,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
586586 // So if the constraint is not yet frozen, we do the same comparison again
587587 // with a frozen constraint, which means that we get a chance to do the
588588 // widening in `fourthTry` before adding to the constraint.
589- if (frozenConstraint) recur(tp1, bounds(tp2).lo)
589+ if (frozenConstraint) recur(tp1, bounds(tp2).lo.boxed )
590590 else isSubTypeWhenFrozen(tp1, tp2)
591591 alwaysTrue || {
592592 if (canConstrain(tp2) && ! approx.low)
@@ -832,7 +832,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
832832 }
833833
834834 def tryBaseType (cls2 : Symbol ) = {
835- val base = nonExprBaseType(tp1, cls2)
835+ val base = nonExprBaseType(tp1, cls2).boxedIfTypeParam(tp1.typeSymbol)
836836 if base.exists && (base ne tp1)
837837 && (! caseLambda.exists || canWidenAbstract || tp1.widen.underlyingClassRef(refinementOK = true ).exists)
838838 then
@@ -856,7 +856,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
856856 && (tp2.isAny || GADTusage (tp1.symbol))
857857
858858 (! caseLambda.exists || canWidenAbstract)
859- && isSubType(hi1, tp2, approx.addLow) && (trustBounds || isSubType(lo1, tp2, approx.addLow))
859+ && isSubType(hi1.boxedIfTypeParam(tp1.symbol) , tp2, approx.addLow) && (trustBounds || isSubType(lo1, tp2, approx.addLow))
860860 || compareGADT
861861 || tryLiftedToThis1
862862 case _ =>
0 commit comments