File tree 2 files changed +15
-3
lines changed
compiler/src/dotty/tools/dotc
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -112,9 +112,9 @@ object Trees {
112
112
* type. (Overridden by empty trees)
113
113
*/
114
114
def withType (tpe : Type )(implicit ctx : Context ): ThisTree [Type ] = {
115
- if (tpe. isInstanceOf [ ErrorType ] )
116
- assert(ctx.mode.is( Mode . Interactive ) || ctx.reporter.errorsReported)
117
- else if (Config .checkTreesConsistent)
115
+ if (Config .checkUnreportedErrors )
116
+ if (tpe. isInstanceOf [ ErrorType ]) assert( ctx.reporter.errorsReported)
117
+ if (Config .checkTreesConsistent)
118
118
checkChildrenTyped(productIterator)
119
119
withTypeUnchecked(tpe)
120
120
}
Original file line number Diff line number Diff line change @@ -106,6 +106,18 @@ object Config {
106
106
*/
107
107
final val checkTypeRefCycles = false
108
108
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
+
109
121
/** If this flag is set, it is checked that class type parameters are
110
122
* only references with NoPrefix or ThisTypes as prefixes. This option
111
123
* is usally disabled, because there are still some legitimate cases where
You can’t perform that action at this time.
0 commit comments