Skip to content

Commit 0c1c596

Browse files
committed
Another optimization
In fact, the isLess relation is irrelevant here. If p >: L <: H and L =:= H and the constraint is satisfiable, then it's safe to replace p by L or H anyway, no matter what other parameters are known to be smaller or larger than p.
1 parent 7811979 commit 0c1c596

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

compiler/src/dotty/tools/dotc/typer/Inferencing.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,7 @@ object Inferencing {
151151
val constraint = ctx.typerState.constraint
152152
constraint.entry(param) match {
153153
case TypeBounds(lo, hi)
154-
if constraint.lower(param).isEmpty && constraint.upper(param).isEmpty &&
155-
(hi frozen_<:< lo) =>
154+
if (hi frozen_<:< lo) =>
156155
// if lower or upper is nonEmpty, the full bounds can't be equal, since
157156
// common type params in lower and upper are eliminated through unification
158157
typr.println(i"replace singleton $param := ${constraint.fullLowerBound(param)}")

0 commit comments

Comments
 (0)