Skip to content

Commit 041d42f

Browse files
committed
Handle subtyping of LazyVals that are in train of being evaluated.
Instead of forcing again, and causing an assertion error, back out assuming that the result is false. Fixes first problem with scala#859.
1 parent 9c38a61 commit 041d42f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
199199
}
200200
compareWild
201201
case tp2: LazyRef =>
202-
isSubType(tp1, tp2.ref)
202+
!tp2.evaluating && isSubType(tp1, tp2.ref)
203203
case tp2: AnnotatedType =>
204204
isSubType(tp1, tp2.tpe) // todo: refine?
205205
case tp2: ThisType =>
@@ -299,7 +299,10 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
299299
}
300300
compareWild
301301
case tp1: LazyRef =>
302-
isSubType(tp1.ref, tp2)
302+
// If `tp1` is in train of being evaluated, don't force it
303+
// because that would cause an assertionError. Return false instead.
304+
// See i859.scala for an example where we hit this case.
305+
!tp1.evaluating && isSubType(tp1.ref, tp2)
303306
case tp1: AnnotatedType =>
304307
isSubType(tp1.tpe, tp2)
305308
case AndType(tp11, tp12) =>

0 commit comments

Comments
 (0)