Skip to content

Commit

Permalink
Backport "Make error reporting resilient to exception thrown while re…
Browse files Browse the repository at this point in the history
…porting" to LTS (#21059)

Backports #20158 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 5, 2024
2 parents c8b0325 + cf74996 commit 52d6c1b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
8 changes: 7 additions & 1 deletion compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import java.io.{BufferedReader, PrintWriter}
import scala.annotation.internal.sharable
import scala.collection.mutable
import core.Decorators.em
import core.handleRecursive

object Reporter {
/** Convert a SimpleReporter into a real Reporter */
Expand Down Expand Up @@ -155,6 +156,12 @@ 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
try
withMode(Mode.Printing)(doReport(dia))
catch case ex: Throwable =>
// #20158: Don't increment the error count, otherwise we might suppress
// the RecursiveOverflow error and not print any error at all.
handleRecursive("error reporting", dia.message, ex)
dia match {
case w: Warning =>
warnings = w :: warnings
Expand All @@ -168,7 +175,6 @@ abstract class Reporter extends interfaces.ReporterResult {
// 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
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
}

if dia.level >= WARNING then
_diagnosticBuf.append(dia)
_consoleReporter.doReport(dia)
_diagnosticBuf.append(dia)
printMessageAndPos(dia, extra)
}
}
Expand Down
17 changes: 17 additions & 0 deletions tests/neg-deep-subtype/mt-deskolemize.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// LTS specific change: -Yno-deep-subtypes makes it crash, in Next is placed in neg/
trait Expr:
type Value
object Expr:
type Of[V] = Expr { type Value = V }
type ExtractValue[F <: Expr] = F match
case Expr.Of[v] => v
import Expr.ExtractValue

class SimpleLoop1 extends Expr:
type Value = ExtractValue[SimpleLoop2]

class SimpleLoop2 extends Expr:
type Value = ExtractValue[SimpleLoop1]

object Test1:
val x: ExtractValue[SimpleLoop1] = 1 // error

0 comments on commit 52d6c1b

Please sign in to comment.