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 {
929
929
/** Flag to suppress inlining, set after overflow */
930
930
private [dotc] var stopInlining : Boolean = false
931
931
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
+
932
943
// Reporters state
933
944
private [dotc] var indent : Int = 0
934
945
@@ -958,6 +969,7 @@ object Contexts {
958
969
uniqueNamedTypes.clear()
959
970
emptyTypeBounds = null
960
971
emptyWildcardBounds = null
972
+ errorsToBeReported = false
961
973
errorTypeMsg.clear()
962
974
sources.clear()
963
975
files.clear()
Original file line number Diff line number Diff line change @@ -157,6 +157,8 @@ abstract class Reporter extends interfaces.ReporterResult {
157
157
case dia : Error =>
158
158
errors = dia :: errors
159
159
_errorCount += 1
160
+ if ctx.typerState.isGlobalCommittable then
161
+ ctx.base.errorsToBeReported = true
160
162
case dia : Info => // nothing to do here
161
163
// match error if d is something else
162
164
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ object Attachment {
117
117
}
118
118
119
119
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" )
121
121
next = new Link (key, value, next)
122
122
}
123
123
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