Skip to content

Commit

Permalink
Backport "Avoid diagnostic message forcing crashing the compiler" to …
Browse files Browse the repository at this point in the history
…LTS (#20803)

Backports #19113 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jun 26, 2024
2 parents 13ed1b5 + 1b7356e commit 912aa20
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ object report:
| An unhandled exception was thrown in the compiler.
| Please file a crash report here:
| https://github.com/lampepfl/dotty/issues/new/choose
| For non-enriched exceptions, compile with -Yno-enrich-error-messages.
|
|$info1
|""".stripMargin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ trait HideNonSensicalMessages extends Reporter {
*/
override def isHidden(dia: Diagnostic)(using Context): Boolean =
super.isHidden(dia) || {
dia.msg.isNonSensical &&
hasErrors && // if there are no errors yet, report even if diagnostic is non-sensical
!ctx.settings.YshowSuppressedErrors.value
hasErrors // if there are no errors yet, report even if diagnostic is non-sensical
&& dia.msg.isNonSensical // defer forcing the message by calling hasErrors first
&& !ctx.settings.YshowSuppressedErrors.value
}
}
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ abstract class Reporter extends interfaces.ReporterResult {
addUnreported(key, 1)
case _ =>
if !isHidden(dia) then // avoid isHidden test for summarized warnings so that message is not forced
markReported(dia)
withMode(Mode.Printing)(doReport(dia))
dia match {
case w: Warning =>
warnings = w :: warnings
Expand All @@ -169,6 +167,8 @@ abstract class Reporter extends interfaces.ReporterResult {
case _: Info => // nothing to do here
// match error if d is something else
}
markReported(dia)
withMode(Mode.Printing)(doReport(dia))
end issueUnconfigured

def issueIfNotSuppressed(dia: Diagnostic)(using Context): Unit =
Expand Down

0 comments on commit 912aa20

Please sign in to comment.