Skip to content

Commit

Permalink
Refine collapsing of equal type bounds in OrderingConstraint
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
EugeneFlesselle committed Apr 17, 2024
1 parent 63810dc commit 8237d09
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
def replaceParamIn(other: TypeParamRef) =
val oldEntry = current.entry(other)
val newEntry = oldEntry.substParam(param, replacement) match
case tp: TypeBounds => current.validBoundsFor(other, tp)
case tp: TypeBounds => current.validBoundsFor(other, tp) match
case TypeBounds(lo, hi) if lo eq hi => lo
case tp => tp
case tp => tp
current = boundsLens.update(this, current, other, newEntry)
var oldDepEntry = oldEntry
Expand Down

0 comments on commit 8237d09

Please sign in to comment.