@@ -37,17 +37,21 @@ 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)
42+ else reporter.report(warning)
43+
4044 def deprecationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
41- reporter.report (new DeprecationWarning (msg, pos))
45+ reportWarning (new DeprecationWarning (msg, pos))
4246
4347 def migrationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
44- reporter.report (new MigrationWarning (msg, pos))
48+ reportWarning (new MigrationWarning (msg, pos))
4549
4650 def uncheckedWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
47- reporter.report (new UncheckedWarning (msg, pos))
51+ reportWarning (new UncheckedWarning (msg, pos))
4852
4953 def featureWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
50- reporter.report (new FeatureWarning (msg, pos))
54+ reportWarning (new FeatureWarning (msg, pos))
5155
5256 def featureWarning (feature : String , featureDescription : String , isScala2Feature : Boolean ,
5357 featureUseSite : Symbol , required : Boolean , pos : SourcePosition ): Unit = {
@@ -69,17 +73,15 @@ trait Reporting { this: Context =>
6973
7074 val msg = s " $featureDescription $req be enabled \n by making the implicit value $fqname visible. $explain"
7175 if (required) error(msg, pos)
72- else reporter.report (new FeatureWarning (msg, pos))
76+ else reportWarning (new FeatureWarning (msg, pos))
7377 }
7478
7579 def warning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
76- reporter.report (new Warning (msg, pos))
80+ reportWarning (new Warning (msg, pos))
7781
7882 def strictWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
7983 if (this .settings.strict.value) error(msg, pos)
80- else reporter.report {
81- new ExtendMessage (() => msg)(_ + " \n (This would be an error under strict mode)" ).warning(pos)
82- }
84+ else reportWarning(new ExtendMessage (() => msg)(_ + " \n (This would be an error under strict mode)" ).warning(pos))
8385
8486 def error (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
8587 reporter.report(new Error (msg, pos))
0 commit comments