Skip to content

Commit 7329957

Browse files
committed
Avoid infinite recursion when comparing recursive types.
The previous scheme goes into an infinite recursion if the recursive type does not contain a reference to itself.
1 parent 226cdb9 commit 7329957

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
381381
compareRefined
382382
case tp2: RecType =>
383383
val tp1stable = ensureStableSingleton(tp1)
384-
isSubType(fixRecs(tp1stable, tp1stable.widenExpr), tp2.substRecThis(tp2, tp1stable))
384+
isSubType(fixRecs(tp1stable, tp1stable.widenExpr), tp2.parent.substRecThis(tp2, tp1stable))
385385
case OrType(tp21, tp22) =>
386386
// Rewrite T1 <: (T211 & T212) | T22 to T1 <: (T211 | T22) and T1 <: (T212 | T22)
387387
// and analogously for T1 <: T21 | (T221 & T222)

0 commit comments

Comments
 (0)