File tree Expand file tree Collapse file tree 4 files changed +29
-1
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -929,6 +929,17 @@ object Contexts {
929929 /** Flag to suppress inlining, set after overflow */
930930 private [dotc] var stopInlining : Boolean = false
931931
932+ /** A variable that records that some error was reported in a globally committable context.
933+ * The error will not necessarlily be emitted, since it could still be that
934+ * the enclosing context will be aborted. The variable is used as a smoke test
935+ * to turn off assertions that might be wrong if the program is erroneous. To
936+ * just test for `ctx.reporter.errorsReported` is not always enough, since it
937+ * could be that the context in which the assertion is tested is a completer context
938+ * that's different from the context where the error was reported. See i13218.scala
939+ * for a test.
940+ */
941+ private [dotc] var errorsToBeReported = false
942+
932943 // Reporters state
933944 private [dotc] var indent : Int = 0
934945
@@ -958,6 +969,7 @@ object Contexts {
958969 uniqueNamedTypes.clear()
959970 emptyTypeBounds = null
960971 emptyWildcardBounds = null
972+ errorsToBeReported = false
961973 errorTypeMsg.clear()
962974 sources.clear()
963975 files.clear()
Original file line number Diff line number Diff line change @@ -157,6 +157,8 @@ abstract class Reporter extends interfaces.ReporterResult {
157157 case dia : Error =>
158158 errors = dia :: errors
159159 _errorCount += 1
160+ if ctx.typerState.isGlobalCommittable then
161+ ctx.base.errorsToBeReported = true
160162 case dia : Info => // nothing to do here
161163 // match error if d is something else
162164
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ object Attachment {
117117 }
118118
119119 final def pushAttachment [V ](key : Key [V ], value : V )(using ctx : Context ): Unit = {
120- assert(! hasAttachment(key) || ctx.reporter.errorsReported , s " duplicate attachment for key $key" )
120+ assert(! hasAttachment(key) || ctx.base.errorsToBeReported , s " duplicate attachment for key $key" )
121121 next = new Link (key, value, next)
122122 }
123123
Original file line number Diff line number Diff line change 1+ class TagTest extends AnyFreeSpec :
2+ " a" - {
3+ " b" in {
4+ class TF [F [_]]
5+ meow // error
6+ }
7+ }
8+
9+ trait AnyFreeSpec :
10+ protected class Wrapper (s : String ):
11+ def - (f : => Unit ): Unit = ???
12+ def in (f : => Unit ): Unit = ???
13+
14+ implicit def wrap (s : String ): Wrapper = ???
You can’t perform that action at this time.
0 commit comments