Skip to content

Commit 9d46ce1

Browse files
committed
Fix 6057: Be more forgiving in LazyRef checking if errors were reported previously
1 parent b537220 commit 9d46ce1

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2438,7 +2438,14 @@ object Types {
24382438
private[this] var myRef: Type = null
24392439
private[this] var computed = false
24402440
def ref(implicit ctx: Context): Type = {
2441-
if (computed) assert(myRef != null)
2441+
if (computed) {
2442+
if (myRef == null) {
2443+
// if errors were reported previously handle this by throwing a CyclicReference
2444+
// instead of crashing immediately. A test case is neg/i6057.scala.
2445+
assert(ctx.reporter.errorsReported)
2446+
CyclicReference(NoDenotation)
2447+
}
2448+
}
24422449
else {
24432450
computed = true
24442451
myRef = refFn(ctx)

0 commit comments

Comments
 (0)