Skip to content

Commit da6fbf8

Browse files
committed
Even in ConstrainResult mode, pruning can succeed
This happens when the param we're trying to prune is already a bound of the current param, so `addParamBound` succeeds without adding any constraint.
1 parent 70e5c70 commit da6fbf8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

compiler/src/dotty/tools/dotc/core/ConstraintHandling.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,16 @@ trait ConstraintHandling[AbstractContext] {
511511
constraint.entry(bound) match {
512512
case NoType => pruneLambdaParams(bound)
513513
case _: TypeBounds =>
514-
if (ctx.mode.is(Mode.ConstrainResult))
514+
val savedConstraint = constraint
515+
val added = addParamBound(bound)
516+
if (!added)
517+
NoType
518+
else if (constraint != savedConstraint && ctx.mode.is(Mode.ConstrainResult)) {
519+
constraint = savedConstraint
515520
NoType
516-
else {
517-
if (!addParamBound(bound)) NoType
518-
else if (fromBelow) defn.NothingType
519-
else defn.AnyType
520521
}
522+
else if (fromBelow) defn.NothingType
523+
else defn.AnyType
521524
case inst =>
522525
prune(inst)
523526
}

0 commit comments

Comments
 (0)