Skip to content

Commit 912aa20

Browse files
Backport "Avoid diagnostic message forcing crashing the compiler" to LTS (#20803)
Backports #19113 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 13ed1b5 + 1b7356e commit 912aa20

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

compiler/src/dotty/tools/dotc/report.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ object report:
158158
| An unhandled exception was thrown in the compiler.
159159
| Please file a crash report here:
160160
| https://github.com/lampepfl/dotty/issues/new/choose
161+
| For non-enriched exceptions, compile with -Yno-enrich-error-messages.
161162
|
162163
|$info1
163164
|""".stripMargin

compiler/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ trait HideNonSensicalMessages extends Reporter {
1313
*/
1414
override def isHidden(dia: Diagnostic)(using Context): Boolean =
1515
super.isHidden(dia) || {
16-
dia.msg.isNonSensical &&
17-
hasErrors && // if there are no errors yet, report even if diagnostic is non-sensical
18-
!ctx.settings.YshowSuppressedErrors.value
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
1919
}
2020
}

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ abstract class Reporter extends interfaces.ReporterResult {
155155
addUnreported(key, 1)
156156
case _ =>
157157
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))
160158
dia match {
161159
case w: Warning =>
162160
warnings = w :: warnings
@@ -169,6 +167,8 @@ abstract class Reporter extends interfaces.ReporterResult {
169167
case _: Info => // nothing to do here
170168
// match error if d is something else
171169
}
170+
markReported(dia)
171+
withMode(Mode.Printing)(doReport(dia))
172172
end issueUnconfigured
173173

174174
def issueIfNotSuppressed(dia: Diagnostic)(using Context): Unit =

0 commit comments

Comments
 (0)