diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index ca4114a82cdc..9ab1a0029277 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -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 */ @@ -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 @@ -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 = diff --git a/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala b/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala index 03b61c393d35..f68bc951a1df 100644 --- a/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala +++ b/compiler/test/dotty/tools/dotc/reporting/TestReporter.scala @@ -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) } } diff --git a/tests/neg-deep-subtype/mt-deskolemize.scala b/tests/neg-deep-subtype/mt-deskolemize.scala new file mode 100644 index 000000000000..8b69af42e308 --- /dev/null +++ b/tests/neg-deep-subtype/mt-deskolemize.scala @@ -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