diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-11-10 15:18:53 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-11-10 15:18:53 +0100 |
commit | 93d3f1201e00c0436d2b2bcd3445ba218e0e1a89 (patch) | |
tree | 562b3c4090abce6500da4f8c7ff4250f40e212b1 /src/dotty/tools/dotc/reporting/Reporter.scala | |
parent | 28c2e04dd33b6389a44460f977a97b8691265994 (diff) | |
download | dotty-93d3f1201e00c0436d2b2bcd3445ba218e0e1a89.tar.gz dotty-93d3f1201e00c0436d2b2bcd3445ba218e0e1a89.tar.bz2 dotty-93d3f1201e00c0436d2b2bcd3445ba218e0e1a89.zip |
Make sure messages are lazily evaluated until `report` in `Reporter`
Diffstat (limited to 'src/dotty/tools/dotc/reporting/Reporter.scala')
-rw-r--r-- | src/dotty/tools/dotc/reporting/Reporter.scala | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index 49bd3e811..60ed18c71 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -38,16 +38,16 @@ trait Reporting { this: Context => reporter.report(new Info(msg, pos)) def deprecationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - reporter.report(msg.deprecationWarning(pos)) + reporter.report(new DeprecationWarning(msg, pos)) def migrationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - reporter.report(msg.migrationWarning(pos)) + reporter.report(new MigrationWarning(msg, pos)) def uncheckedWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - reporter.report(msg.uncheckedWarning(pos)) + reporter.report(new UncheckedWarning(msg, pos)) def featureWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - reporter.report(msg.featureWarning(pos)) + reporter.report(new FeatureWarning(msg, pos)) def featureWarning(feature: String, featureDescription: String, isScala2Feature: Boolean, featureUseSite: Symbol, required: Boolean, pos: SourcePosition): Unit = { @@ -73,23 +73,27 @@ trait Reporting { this: Context => } def warning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - reporter.report(msg.warning(pos)) + reporter.report(new Warning(msg, pos)) def strictWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = if (this.settings.strict.value) error(msg, pos) - else warning(msg.mapMsg(_ + "\n(This would be an error under strict mode)"), pos) + else reporter.report { + new ExtendMessage(() => msg)(_ + "\n(This would be an error under strict mode)").warning(pos) + } def error(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - reporter.report(msg.error(pos)) + reporter.report(new Error(msg, pos)) def errorOrMigrationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = if (ctx.scala2Mode) migrationWarning(msg, pos) else error(msg, pos) def restrictionError(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - error(msg.mapMsg(m => s"Implementation restriction: $m"), pos) + reporter.report { + new ExtendMessage(() => msg)(m => s"Implementation restriction: $m").error(pos) + } def incompleteInputError(msg: Message, pos: SourcePosition = NoSourcePosition)(implicit ctx: Context): Unit = - reporter.incomplete(msg.error(pos))(ctx) + reporter.incomplete(new Error(msg, pos))(ctx) /** Log msg if settings.log contains the current phase. * See [[config.CompilerCommand#explainAdvanced]] for the exact meaning of @@ -236,7 +240,7 @@ abstract class Reporter extends interfaces.ReporterResult { override def default(key: String) = 0 } - def report(d: MessageContainer)(implicit ctx: Context): Unit = + def report(d: => MessageContainer)(implicit ctx: Context): Unit = if (!isHidden(d)) { doReport(d)(ctx.addMode(Mode.Printing)) d match { |