@@ -37,17 +37,21 @@ trait Reporting { this: Context =>
37
37
def echo (msg : => String , pos : SourcePosition = NoSourcePosition ): Unit =
38
38
reporter.report(new Info (msg, pos))
39
39
40
+ def reportWarning (warning: Warning ): Unit =
41
+ if (this .settings.XfatalWarnings .value) error(warning.contained, warning.pos)
42
+ else reporter.report(warning)
43
+
40
44
def deprecationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
41
- reporter.report (new DeprecationWarning (msg, pos))
45
+ reportWarning (new DeprecationWarning (msg, pos))
42
46
43
47
def migrationWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
44
- reporter.report (new MigrationWarning (msg, pos))
48
+ reportWarning (new MigrationWarning (msg, pos))
45
49
46
50
def uncheckedWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
47
- reporter.report (new UncheckedWarning (msg, pos))
51
+ reportWarning (new UncheckedWarning (msg, pos))
48
52
49
53
def featureWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
50
- reporter.report (new FeatureWarning (msg, pos))
54
+ reportWarning (new FeatureWarning (msg, pos))
51
55
52
56
def featureWarning (feature : String , featureDescription : String , isScala2Feature : Boolean ,
53
57
featureUseSite : Symbol , required : Boolean , pos : SourcePosition ): Unit = {
@@ -69,17 +73,15 @@ trait Reporting { this: Context =>
69
73
70
74
val msg = s " $featureDescription $req be enabled \n by making the implicit value $fqname visible. $explain"
71
75
if (required) error(msg, pos)
72
- else reporter.report (new FeatureWarning (msg, pos))
76
+ else reportWarning (new FeatureWarning (msg, pos))
73
77
}
74
78
75
79
def warning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
76
- reporter.report (new Warning (msg, pos))
80
+ reportWarning (new Warning (msg, pos))
77
81
78
82
def strictWarning (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
79
83
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))
83
85
84
86
def error (msg : => Message , pos : SourcePosition = NoSourcePosition ): Unit =
85
87
reporter.report(new Error (msg, pos))
0 commit comments