Skip to content

Commit

Permalink
Specialize mapBufferedMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
mbovel committed Apr 25, 2024
1 parent 61aeabf commit ace332c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class ExploringReporter extends StoreReporter(null, fromTyperState = false):
override def removeBufferedMessages(using Context): List[Diagnostic] =
try infos.toList finally reset()

override def mapBufferedMessages(f: Diagnostic => Diagnostic)(using Context): Unit =
infos.mapInPlace(f)

def reset(): Unit = infos.clear()

end ExploringReporter
end ExploringReporter
4 changes: 1 addition & 3 deletions compiler/src/dotty/tools/dotc/reporting/Reporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,7 @@ abstract class Reporter extends interfaces.ReporterResult {
def removeBufferedMessages(using Context): List[Diagnostic] = Nil

/** If this reporter buffers messages, apply `f` to all buffered messages. */
def mapBufferedMessages(f: Diagnostic => Diagnostic)(using Context): Unit =
val mappedDiagnostics = removeBufferedMessages.map(f)
mappedDiagnostics.foreach(report)
def mapBufferedMessages(f: Diagnostic => Diagnostic)(using Context): Unit = ()

/** Issue all messages in this reporter to next outer one, or make sure they are written. */
def flush()(using Context): Unit =
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/reporting/StoreReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ class StoreReporter(outer: Reporter | Null = Reporter.NoReporter, fromTyperState
if (infos != null) try infos.uncheckedNN.toList finally infos = null
else Nil

override def mapBufferedMessages(f: Diagnostic => Diagnostic)(using Context): Unit =
if infos != null then infos.uncheckedNN.mapInPlace(f)

override def pendingMessages(using Context): List[Diagnostic] =
if (infos != null) infos.uncheckedNN.toList else Nil

Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,7 @@ trait Applications extends Compatibility {
case _ => dia
case msg => dia
case dia => dia
case _ => ()

// Try once with original prototype and once (if different) with tupled one.
// The reason we need to try both is that the decision whether to use tupled
Expand Down

0 comments on commit ace332c

Please sign in to comment.