From f147aedd65407056e0682e3c15f5a7265b96ffa1 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Mon, 14 Nov 2016 13:22:17 +0100 Subject: Make sure all `Message` creation is by name --- src/dotty/tools/dotc/parsing/Parsers.scala | 14 +++++++------- src/dotty/tools/dotc/reporting/Reporter.scala | 26 +++++++++++++------------- 2 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src') 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 = { -- cgit v1.2.3