File tree 3 files changed +18
-8
lines changed
compiler/src/dotty/tools/dotc
3 files changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,6 @@ object report:
155
155
| An unhandled exception was thrown in the compiler.
156
156
| Please file a crash report here:
157
157
| https://github.com/lampepfl/dotty/issues/new/choose
158
- | For non-enriched exceptions, compile with -Yno-enrich-error-messages.
159
158
|
160
159
| $info1
161
160
| """ .stripMargin
Original file line number Diff line number Diff line change @@ -13,8 +13,19 @@ trait HideNonSensicalMessages extends Reporter {
13
13
*/
14
14
override def isHidden (dia : Diagnostic )(using Context ): Boolean =
15
15
super .isHidden(dia) || {
16
- hasErrors // if there are no errors yet, report even if diagnostic is non-sensical
17
- && dia.msg.isNonSensical // defer forcing the message by calling hasErrors first
18
- && ! ctx.settings.YshowSuppressedErrors .value
16
+ (if ! errorsReported && dia.isInstanceOf [Diagnostic .Error ] then
17
+ // Bump up errorCount so hasErrors is true while forcing the message.
18
+ // We use errorsReported as a predicate for broken code.
19
+ // So now any forcing won't cause, for instance,
20
+ // assertion errors and thus compiler crashes.
21
+ // Some messages, once forced, run more code
22
+ // to generate useful hints for the user.
23
+ try
24
+ _errorCount += 1
25
+ dia.msg.isNonSensical
26
+ finally _errorCount -= 1 // decrease rather than reset the value so we only ever decrease by 1
27
+ else dia.msg.isNonSensical) &&
28
+ hasErrors && // if there are no errors yet, report even if diagnostic is non-sensical
29
+ ! ctx.settings.YshowSuppressedErrors .value
19
30
}
20
31
}
Original file line number Diff line number Diff line change @@ -92,8 +92,8 @@ abstract class Reporter extends interfaces.ReporterResult {
92
92
93
93
private def isIncompleteChecking = incompleteHandler ne defaultIncompleteHandler
94
94
95
- private var _errorCount = 0
96
- private var _warningCount = 0
95
+ protected var _errorCount = 0
96
+ protected var _warningCount = 0
97
97
98
98
/** The number of errors reported by this reporter (ignoring outer reporters) */
99
99
def errorCount : Int = _errorCount
@@ -155,6 +155,8 @@ abstract class Reporter extends interfaces.ReporterResult {
155
155
addUnreported(key, 1 )
156
156
case _ =>
157
157
if ! isHidden(dia) then // avoid isHidden test for summarized warnings so that message is not forced
158
+ markReported(dia)
159
+ withMode(Mode .Printing )(doReport(dia))
158
160
dia match {
159
161
case w : Warning =>
160
162
warnings = w :: warnings
@@ -167,8 +169,6 @@ abstract class Reporter extends interfaces.ReporterResult {
167
169
case _ : Info => // nothing to do here
168
170
// match error if d is something else
169
171
}
170
- markReported(dia)
171
- withMode(Mode .Printing )(doReport(dia))
172
172
end issueUnconfigured
173
173
174
174
def issueIfNotSuppressed (dia : Diagnostic )(using Context ): Unit =
You can’t perform that action at this time.
0 commit comments