Skip to content

Commit f147aed

Browse files
committed
Make sure all Message creation is by name
1 parent 93d3f12 commit f147aed

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ object Parsers {
9999
/** Issue an error at given offset if beyond last error offset
100100
* and update lastErrorOffset.
101101
*/
102-
def syntaxError(msg: Message, offset: Int = in.offset): Unit =
102+
def syntaxError(msg: => Message, offset: Int = in.offset): Unit =
103103
if (offset > lastErrorOffset) {
104104
syntaxError(msg, Position(offset))
105105
lastErrorOffset = in.offset
@@ -108,7 +108,7 @@ object Parsers {
108108
/** Unconditionally issue an error at given position, without
109109
* updating lastErrorOffset.
110110
*/
111-
def syntaxError(msg: Message, pos: Position): Unit =
111+
def syntaxError(msg: => Message, pos: Position): Unit =
112112
ctx.error(msg, source atPos pos)
113113

114114
}
@@ -215,23 +215,23 @@ object Parsers {
215215
}
216216
}
217217

218-
def warning(msg: Message, sourcePos: SourcePosition) =
218+
def warning(msg: => Message, sourcePos: SourcePosition) =
219219
ctx.warning(msg, sourcePos)
220220

221-
def warning(msg: Message, offset: Int = in.offset) =
221+
def warning(msg: => Message, offset: Int = in.offset) =
222222
ctx.warning(msg, source atPos Position(offset))
223223

224-
def deprecationWarning(msg: Message, offset: Int = in.offset) =
224+
def deprecationWarning(msg: => Message, offset: Int = in.offset) =
225225
ctx.deprecationWarning(msg, source atPos Position(offset))
226226

227227
/** Issue an error at current offset taht input is incomplete */
228-
def incompleteInputError(msg: Message) =
228+
def incompleteInputError(msg: => Message) =
229229
ctx.incompleteInputError(msg, source atPos Position(in.offset))
230230

231231
/** If at end of file, issue an incompleteInputError.
232232
* Otherwise issue a syntax error and skip to next safe point.
233233
*/
234-
def syntaxErrorOrIncomplete(msg: Message) =
234+
def syntaxErrorOrIncomplete(msg: => Message) =
235235
if (in.token == EOF) incompleteInputError(msg)
236236
else {
237237
syntaxError(msg)

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

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ trait Reporting { this: Context =>
9292
new ExtendMessage(() => msg)(m => s"Implementation restriction: $m").error(pos)
9393
}
9494

95-
def incompleteInputError(msg: Message, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
95+
def incompleteInputError(msg: => Message, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
9696
reporter.incomplete(new Error(msg, pos))(ctx)
9797

9898
/** Log msg if settings.log contains the current phase.
@@ -196,7 +196,7 @@ trait Reporting { this: Context =>
196196
abstract class Reporter extends interfaces.ReporterResult {
197197

198198
/** Report a diagnostic */
199-
def doReport(d: MessageContainer)(implicit ctx: Context): Unit
199+
def doReport(m: MessageContainer)(implicit ctx: Context): Unit
200200

201201
/** Whether very long lines can be truncated. This exists so important
202202
* debugging information (like printing the classpath) is not rendered
@@ -240,22 +240,22 @@ abstract class Reporter extends interfaces.ReporterResult {
240240
override def default(key: String) = 0
241241
}
242242

243-
def report(d: => MessageContainer)(implicit ctx: Context): Unit =
244-
if (!isHidden(d)) {
245-
doReport(d)(ctx.addMode(Mode.Printing))
246-
d match {
247-
case d: ConditionalWarning if !d.enablingOption.value => unreportedWarnings(d.enablingOption.name) += 1
248-
case d: Warning => warningCount += 1
249-
case d: Error =>
250-
errors = d :: errors
243+
def report(m: MessageContainer)(implicit ctx: Context): Unit =
244+
if (!isHidden(m)) {
245+
doReport(m)(ctx.addMode(Mode.Printing))
246+
m match {
247+
case m: ConditionalWarning if !m.enablingOption.value => unreportedWarnings(m.enablingOption.name) += 1
248+
case m: Warning => warningCount += 1
249+
case m: Error =>
250+
errors = m :: errors
251251
errorCount += 1
252-
case d: Info => // nothing to do here
252+
case m: Info => // nothing to do here
253253
// match error if d is something else
254254
}
255255
}
256256

257-
def incomplete(d: MessageContainer)(implicit ctx: Context): Unit =
258-
incompleteHandler(d)(ctx)
257+
def incomplete(m: MessageContainer)(implicit ctx: Context): Unit =
258+
incompleteHandler(m)(ctx)
259259

260260
/** Summary of warnings and errors */
261261
def summary: String = {

test/dotty/tools/dotc/reporting/TestMessageLaziness.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ class TestMessageLaziness extends DottyTest {
1616

1717
class NonchalantReporter(implicit ctx: Context) extends Reporter
1818
with UniqueMessagePositions with HideNonSensicalMessages {
19-
def doReport(d: MessageContainer)(implicit ctx: Context) = ???
19+
def doReport(m: MessageContainer)(implicit ctx: Context) = ???
2020

21-
override def report(d: => MessageContainer)(implicit ctx: Context) = ()
21+
override def report(m: MessageContainer)(implicit ctx: Context) = ()
2222
}
2323

2424
case class LazyError() extends Message(1000) {

0 commit comments

Comments
 (0)