aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-11-14 13:22:17 +0100
committerFelix Mulder <felix.mulder@gmail.com>2016-11-14 13:22:17 +0100
commitf147aedd65407056e0682e3c15f5a7265b96ffa1 (patch)
tree03e132845a8fc9d1022437a10ccc2a4e8e41c67b
parent93d3f1201e00c0436d2b2bcd3445ba218e0e1a89 (diff)
downloaddotty-f147aedd65407056e0682e3c15f5a7265b96ffa1.tar.gz
dotty-f147aedd65407056e0682e3c15f5a7265b96ffa1.tar.bz2
dotty-f147aedd65407056e0682e3c15f5a7265b96ffa1.zip
Make sure all `Message` creation is by name
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala14
-rw-r--r--src/dotty/tools/dotc/reporting/Reporter.scala26
-rw-r--r--test/dotty/tools/dotc/reporting/TestMessageLaziness.scala4
3 files changed, 22 insertions, 22 deletions
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index f442c13b3..974d98d6a 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -99,7 +99,7 @@ object Parsers {
/** Issue an error at given offset if beyond last error offset
* and update lastErrorOffset.
*/
- def syntaxError(msg: Message, offset: Int = in.offset): Unit =
+ def syntaxError(msg: => Message, offset: Int = in.offset): Unit =
if (offset > lastErrorOffset) {
syntaxError(msg, Position(offset))
lastErrorOffset = in.offset
@@ -108,7 +108,7 @@ object Parsers {
/** Unconditionally issue an error at given position, without
* updating lastErrorOffset.
*/
- def syntaxError(msg: Message, pos: Position): Unit =
+ def syntaxError(msg: => Message, pos: Position): Unit =
ctx.error(msg, source atPos pos)
}
@@ -215,23 +215,23 @@ object Parsers {
}
}
- def warning(msg: Message, sourcePos: SourcePosition) =
+ def warning(msg: => Message, sourcePos: SourcePosition) =
ctx.warning(msg, sourcePos)
- def warning(msg: Message, offset: Int = in.offset) =
+ def warning(msg: => Message, offset: Int = in.offset) =
ctx.warning(msg, source atPos Position(offset))
- def deprecationWarning(msg: Message, offset: Int = in.offset) =
+ def deprecationWarning(msg: => Message, offset: Int = in.offset) =
ctx.deprecationWarning(msg, source atPos Position(offset))
/** Issue an error at current offset taht input is incomplete */
- def incompleteInputError(msg: Message) =
+ def incompleteInputError(msg: => Message) =
ctx.incompleteInputError(msg, source atPos Position(in.offset))
/** If at end of file, issue an incompleteInputError.
* Otherwise issue a syntax error and skip to next safe point.
*/
- def syntaxErrorOrIncomplete(msg: Message) =
+ def syntaxErrorOrIncomplete(msg: => Message) =
if (in.token == EOF) incompleteInputError(msg)
else {
syntaxError(msg)
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala
index 60ed18c71..8477cfe28 100644
--- a/src/dotty/tools/dotc/reporting/Reporter.scala
+++ b/src/dotty/tools/dotc/reporting/Reporter.scala
@@ -92,7 +92,7 @@ trait Reporting { this: Context =>
new ExtendMessage(() => msg)(m => s"Implementation restriction: $m").error(pos)
}
- def incompleteInputError(msg: Message, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
+ def incompleteInputError(msg: => Message, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit =
reporter.incomplete(new Error(msg, pos))(ctx)
/** Log msg if settings.log contains the current phase.
@@ -196,7 +196,7 @@ trait Reporting { this: Context =>
abstract class Reporter extends interfaces.ReporterResult {
/** Report a diagnostic */
- def doReport(d: MessageContainer)(implicit ctx: Context): Unit
+ def doReport(m: MessageContainer)(implicit ctx: Context): Unit
/** Whether very long lines can be truncated. This exists so important
* debugging information (like printing the classpath) is not rendered
@@ -240,22 +240,22 @@ abstract class Reporter extends interfaces.ReporterResult {
override def default(key: String) = 0
}
- def report(d: => MessageContainer)(implicit ctx: Context): Unit =
- if (!isHidden(d)) {
- doReport(d)(ctx.addMode(Mode.Printing))
- d match {
- case d: ConditionalWarning if !d.enablingOption.value => unreportedWarnings(d.enablingOption.name) += 1
- case d: Warning => warningCount += 1
- case d: Error =>
- errors = d :: errors
+ def report(m: MessageContainer)(implicit ctx: Context): Unit =
+ if (!isHidden(m)) {
+ doReport(m)(ctx.addMode(Mode.Printing))
+ m match {
+ case m: ConditionalWarning if !m.enablingOption.value => unreportedWarnings(m.enablingOption.name) += 1
+ case m: Warning => warningCount += 1
+ case m: Error =>
+ errors = m :: errors
errorCount += 1
- case d: Info => // nothing to do here
+ case m: Info => // nothing to do here
// match error if d is something else
}
}
- def incomplete(d: MessageContainer)(implicit ctx: Context): Unit =
- incompleteHandler(d)(ctx)
+ def incomplete(m: MessageContainer)(implicit ctx: Context): Unit =
+ incompleteHandler(m)(ctx)
/** Summary of warnings and errors */
def summary: String = {
diff --git a/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala b/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala
index fe85edda6..6892739e8 100644
--- a/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala
+++ b/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala
@@ -16,9 +16,9 @@ class TestMessageLaziness extends DottyTest {
class NonchalantReporter(implicit ctx: Context) extends Reporter
with UniqueMessagePositions with HideNonSensicalMessages {
- def doReport(d: MessageContainer)(implicit ctx: Context) = ???
+ def doReport(m: MessageContainer)(implicit ctx: Context) = ???
- override def report(d: => MessageContainer)(implicit ctx: Context) = ()
+ override def report(m: MessageContainer)(implicit ctx: Context) = ()
}
case class LazyError() extends Message(1000) {