@@ -1077,7 +1077,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1077
1077
// constraint after isSubArgs, but we now pick the constraint after the dealiased test.
1078
1078
// There's one test in shapeless/deriving that had to be disabled
1079
1079
// (modules/deriving/src/test/scala/shapeless3/deriving/deriving.scala, value v7 in the functor test).
1080
- sufficientEither (
1080
+ sufficientEither2 (
1081
1081
isSubArgs(args1, args2, tp1, tparams),
1082
1082
recur(tp1.superType, tp2.superType))
1083
1083
else
@@ -1606,6 +1606,20 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1606
1606
true
1607
1607
else op2
1608
1608
1609
+ private def sufficientEither2 (op1 : => Boolean , op2 : => Boolean ): Boolean =
1610
+ val preConstraint = constraint
1611
+ if op1 then
1612
+ if constraint ne preConstraint then
1613
+ // check whether `op2` generates a weaker constraint than `op1`
1614
+ val leftConstraint = constraint
1615
+ constraint = preConstraint
1616
+ if ! (op2 && subsumes(leftConstraint, constraint, preConstraint)) then
1617
+ if constr != noPrinter && ! subsumes(constraint, leftConstraint, preConstraint) then
1618
+ constr.println(i " CUT - prefer $leftConstraint over $constraint" )
1619
+ constraint = leftConstraint
1620
+ true
1621
+ else false
1622
+
1609
1623
/** Returns true iff the result of evaluating either `op1` or `op2` is true, keeping the smaller constraint if any.
1610
1624
* E.g., if
1611
1625
*
0 commit comments