Skip to content

Commit 22c0f91

Browse files
Merge pull request #3734 from dotty-staging/fix-#3383
Fix #3383: Don't fail on unreported errors
2 parents ff4b19c + 8afd9b3 commit 22c0f91

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ object Trees {
113113
*/
114114
def withType(tpe: Type)(implicit ctx: Context): ThisTree[Type] = {
115115
if (tpe.isInstanceOf[ErrorType])
116-
assert(ctx.mode.is(Mode.Interactive) || ctx.reporter.errorsReported)
116+
assert(!Config.checkUnreportedErrors || ctx.reporter.errorsReported)
117117
else if (Config.checkTreesConsistent)
118118
checkChildrenTyped(productIterator)
119119
withTypeUnchecked(tpe)

compiler/src/dotty/tools/dotc/config/Config.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,18 @@ object Config {
106106
*/
107107
final val checkTypeRefCycles = false
108108

109+
/** If this flag is set, we check that types assigned to trees are error types only
110+
* if some error was already reported. There are complicicated scenarios where this
111+
* is not true. An example is TestNonCyclic in posTwice. If we remove the
112+
* first (unused) import `import dotty.tools.dotc.core.Types.Type` in `CompilationUnit`,
113+
* we end up assigning a CyclicReference error type to an import expression `annotation`
114+
* before the cyclic reference is reported. What happens is that the error was reported
115+
* as a result of a completion in a not-yet committed typerstate. So we cannot enforce
116+
* this in all circumstances. But since it is almost always true it is useful to
117+
* keep the Config option for debugging.
118+
*/
119+
final val checkUnreportedErrors = false
120+
109121
/** If this flag is set, it is checked that class type parameters are
110122
* only references with NoPrefix or ThisTypes as prefixes. This option
111123
* is usally disabled, because there are still some legitimate cases where

0 commit comments

Comments
 (0)