Skip to content

Commit 677ae31

Browse files
committed
Include TypeVars in cyclic checking
Without the additional case, scalatest fails.
1 parent 5a57ae5 commit 677ae31

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
323323
case NoType => tp
324324
case TypeBounds(lo, hi) => if lo eq hi then recur(lo, fromBelow) else tp
325325
case inst => recur(inst, fromBelow)
326-
case tp: TypeVar if false => // TODO: needed?
326+
case tp: TypeVar =>
327327
val underlying1 = recur(tp.underlying, fromBelow)
328328
if underlying1 ne tp.underlying then underlying1 else tp
329329
case _ => tp
@@ -399,7 +399,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
399399
*/
400400
def replace(param: TypeParamRef, tp: Type)(implicit ctx: Context): OrderingConstraint =
401401
val replacement = tp.dealiasKeepAnnots.stripTypeVar
402-
if param == replacement then this
402+
if param == replacement then this.checkNonCyclic()
403403
else
404404
assert(replacement.isValueTypeOrLambda)
405405
var current =
@@ -518,7 +518,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
518518
val TypeParamRef(binder, n) = tvar.origin
519519
if (binder eq tl) tvar.setOrigin(tl1.paramRefs(n))
520520
}
521-
constr.println(i"renamd $this to $current")
521+
constr.println(i"renamed $this to $current")
522522
current.checkNonCyclic()
523523
}
524524

@@ -602,6 +602,8 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
602602
case NoType =>
603603
case TypeBounds(lo, hi) => if lo eq hi then recur(lo)
604604
case inst => recur(inst)
605+
case tp: TypeVar =>
606+
recur(tp.underlying)
605607
case TypeBounds(lo, hi) =>
606608
recur(lo)
607609
recur(hi)

0 commit comments

Comments
 (0)