Skip to content

Commit

Permalink
Merge pull request #6104 from dotty-staging/fix-#6057ompt
Browse files Browse the repository at this point in the history
Fix 6057: Be more forgiving in LazyRef checking
  • Loading branch information
odersky committed Mar 19, 2019
2 parents 3ab65ae + 67a0cec commit 7e16aca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Expand Up @@ -2438,7 +2438,14 @@ object Types {
private[this] var myRef: Type = null
private[this] var computed = false
def ref(implicit ctx: Context): Type = {
if (computed) assert(myRef != null)
if (computed) {
if (myRef == null) {
// if errors were reported previously handle this by throwing a CyclicReference
// instead of crashing immediately. A test case is neg/i6057.scala.
assert(ctx.reporter.errorsReported)
CyclicReference(NoDenotation)
}
}
else {
computed = true
myRef = refFn(ctx)
Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i6057.scala
@@ -0,0 +1,4 @@
class i0[i1] {
type i2 <: i0[i2]
val i3: i2[i4] {} // error
}

0 comments on commit 7e16aca

Please sign in to comment.