Skip to content

Commit f4cbf5d

Browse files
committed
Make cycle checking complete
Also detect cycles containing aliases and annotated types.
1 parent fa8e36b commit f4cbf5d

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,15 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
326326
case tp: TypeVar =>
327327
val underlying1 = recur(tp.underlying, fromBelow)
328328
if underlying1 ne tp.underlying then underlying1 else tp
329-
case _ => tp
329+
case tp: AnnotatedType =>
330+
val parent1 = recur(tp.parent, fromBelow)
331+
if parent1 ne tp.parent then tp.derivedAnnotatedType(parent1, tp.annot) else tp
332+
case _ =>
333+
val tp1 = tp.dealiasKeepAnnots
334+
if tp1 ne tp then
335+
val tp2 = recur(tp1, fromBelow)
336+
if tp2 ne tp1 then tp2 else tp
337+
else tp
330338

331339
inst match
332340
case bounds: TypeBounds =>
@@ -608,6 +616,8 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
608616
recur(lo)
609617
recur(hi)
610618
case _ =>
619+
val tp1 = tp.dealias
620+
if tp1 ne tp then recur(tp1)
611621

612622
recur(entry(param))
613623
end checkNonCyclic

0 commit comments

Comments
 (0)