Skip to content

Commit 90cc0be

Browse files
committed
Try another variant
1 parent 965efd9 commit 90cc0be

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

Diff for: compiler/src/dotty/tools/dotc/core/TypeComparer.scala

+15-1
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
10771077
// constraint after isSubArgs, but we now pick the constraint after the dealiased test.
10781078
// There's one test in shapeless/deriving that had to be disabled
10791079
// (modules/deriving/src/test/scala/shapeless3/deriving/deriving.scala, value v7 in the functor test).
1080-
sufficientEither(
1080+
sufficientEither2(
10811081
isSubArgs(args1, args2, tp1, tparams),
10821082
recur(tp1.superType, tp2.superType))
10831083
else
@@ -1606,6 +1606,20 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
16061606
true
16071607
else op2
16081608

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+
16091623
/** Returns true iff the result of evaluating either `op1` or `op2` is true, keeping the smaller constraint if any.
16101624
* E.g., if
16111625
*

0 commit comments

Comments
 (0)