Skip to content

Commit 8237d09

Browse files
Refine collapsing of equal type bounds in OrderingConstraint
`ConstraintHandling#addOneBound` uses `constraint.replace` when it detects the two bounds of a constraint are equal. `ConstraintHandling#replace` then recursively replaces the parameter in the bounds of all other constraints where it appears, which can transform other constraint entries to also have equal bounds. This PR applies the same collapsing logic for these transitive updates.
1 parent 63810dc commit 8237d09

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,9 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
708708
def replaceParamIn(other: TypeParamRef) =
709709
val oldEntry = current.entry(other)
710710
val newEntry = oldEntry.substParam(param, replacement) match
711-
case tp: TypeBounds => current.validBoundsFor(other, tp)
711+
case tp: TypeBounds => current.validBoundsFor(other, tp) match
712+
case TypeBounds(lo, hi) if lo eq hi => lo
713+
case tp => tp
712714
case tp => tp
713715
current = boundsLens.update(this, current, other, newEntry)
714716
var oldDepEntry = oldEntry

0 commit comments

Comments
 (0)