Skip to content

Commit 49c8744

Browse files
committed
Make sure reportWarning doesn't break by name
Diagnostic messages are contained within a `MessageContainer` which takes the message by name. This is in order for the compiler to be able to throw away messages without evaluting potentially costly operations. Calling `.contained` breaks this laziness.
1 parent 5514655 commit 49c8744

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ trait Reporting { this: Context =>
3737
def echo(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
3838
reporter.report(new Info(msg, pos))
3939

40-
def reportWarning(warning:Warning):Unit =
41-
if(this.settings.XfatalWarnings.value) error(warning.contained, warning.pos)
40+
def reportWarning(warning: Warning): Unit =
41+
if (this.settings.XfatalWarnings.value) reporter.report(warning.toError)
4242
else reporter.report(warning)
4343

4444
def deprecationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit =

compiler/src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ object messages {
3131
class Warning(
3232
msgFn: => Message,
3333
pos: SourcePosition
34-
) extends MessageContainer(msgFn, pos, WARNING)
34+
) extends MessageContainer(msgFn, pos, WARNING) {
35+
def toError: Error = new Error(msgFn, pos)
36+
}
3537

3638
class Info(
3739
msgFn: => Message,

0 commit comments

Comments
 (0)