@@ -23,7 +23,7 @@ import typer.ProtoTypes.constrained
23
23
import typer .Applications .productSelectorTypes
24
24
import reporting .trace
25
25
import annotation .constructorOnly
26
- import cc .{CapturingType , derivedCapturingType , CaptureSet , stripCapturing , isBoxedCapturing , boxedUnlessFun }
26
+ import cc .{CapturingType , derivedCapturingType , CaptureSet , stripCapturing , isBoxedCapturing , boxed , boxedUnlessFun , boxedIfTypeParam }
27
27
28
28
/** Provides methods to compare types.
29
29
*/
@@ -426,7 +426,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
426
426
case tp2 : TypeParamRef => constraint.isLess(tp1, tp2)
427
427
case _ => false
428
428
} ||
429
- isSubTypeWhenFrozen(bounds(tp1).hi, tp2) || {
429
+ isSubTypeWhenFrozen(bounds(tp1).hi.boxed , tp2) || {
430
430
if (canConstrain(tp1) && ! approx.high)
431
431
addConstraint(tp1, tp2, fromBelow = false ) && flagNothingBound
432
432
else thirdTry
@@ -547,7 +547,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
547
547
|| narrowGADTBounds(tp2, tp1, approx, isUpper = false ))
548
548
&& (isBottom(tp1) || GADTusage (tp2.symbol))
549
549
550
- isSubApproxHi(tp1, info2.lo) && (trustBounds || isSubApproxHi(tp1, info2.hi))
550
+ isSubApproxHi(tp1, info2.lo.boxedIfTypeParam(tp2.symbol) ) && (trustBounds || isSubApproxHi(tp1, info2.hi))
551
551
|| compareGADT
552
552
|| tryLiftedToThis2
553
553
|| fourthTry
@@ -586,7 +586,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
586
586
// So if the constraint is not yet frozen, we do the same comparison again
587
587
// with a frozen constraint, which means that we get a chance to do the
588
588
// 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 )
590
590
else isSubTypeWhenFrozen(tp1, tp2)
591
591
alwaysTrue || {
592
592
if (canConstrain(tp2) && ! approx.low)
@@ -832,7 +832,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
832
832
}
833
833
834
834
def tryBaseType (cls2 : Symbol ) = {
835
- val base = nonExprBaseType(tp1, cls2)
835
+ val base = nonExprBaseType(tp1, cls2).boxedIfTypeParam(tp1.typeSymbol)
836
836
if base.exists && (base ne tp1)
837
837
&& (! caseLambda.exists || canWidenAbstract || tp1.widen.underlyingClassRef(refinementOK = true ).exists)
838
838
then
@@ -856,7 +856,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
856
856
&& (tp2.isAny || GADTusage (tp1.symbol))
857
857
858
858
(! 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))
860
860
|| compareGADT
861
861
|| tryLiftedToThis1
862
862
case _ =>
0 commit comments