Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Include TypeVars in cyclic checking
Without the additional case, scalatest fails.
  • Loading branch information
odersky committed Apr 30, 2020
commit 677ae31ef48bcf596e93fb58e7b8f02c2e532916
8 changes: 5 additions & 3 deletions compiler/src/dotty/tools/dotc/core/OrderingConstraint.scala
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
case NoType => tp
case TypeBounds(lo, hi) => if lo eq hi then recur(lo, fromBelow) else tp
case inst => recur(inst, fromBelow)
case tp: TypeVar if false => // TODO: needed?
case tp: TypeVar =>
val underlying1 = recur(tp.underlying, fromBelow)
if underlying1 ne tp.underlying then underlying1 else tp
case _ => tp
Expand Down Expand Up @@ -399,7 +399,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
*/
def replace(param: TypeParamRef, tp: Type)(implicit ctx: Context): OrderingConstraint =
val replacement = tp.dealiasKeepAnnots.stripTypeVar
if param == replacement then this
if param == replacement then this.checkNonCyclic()
else
assert(replacement.isValueTypeOrLambda)
var current =
Expand Down Expand Up @@ -518,7 +518,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
val TypeParamRef(binder, n) = tvar.origin
if (binder eq tl) tvar.setOrigin(tl1.paramRefs(n))
}
constr.println(i"renamd $this to $current")
constr.println(i"renamed $this to $current")
current.checkNonCyclic()
}

Expand Down Expand Up @@ -602,6 +602,8 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
case NoType =>
case TypeBounds(lo, hi) => if lo eq hi then recur(lo)
case inst => recur(inst)
case tp: TypeVar =>
recur(tp.underlying)
case TypeBounds(lo, hi) =>
recur(lo)
recur(hi)
Expand Down