Skip to content

Commit d39bca0

Browse files
authored
Merge pull request #6346 from dotty-staging/change-warnings
Revert deprecation warnings disable
2 parents cdf5b1e + dd8d03a commit d39bca0

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

compiler/src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,18 @@ trait Reporting { this: Context =>
5050

5151
def reportWarning(warning: Warning): Unit =
5252
if (!this.settings.silentWarnings.value) {
53-
if (this.settings.XfatalWarnings.value) reporter.report(warning.toError)
53+
if (this.settings.XfatalWarnings.value)
54+
warning match {
55+
case warning: ConditionalWarning if !warning.enablingOption.value =>
56+
reporter.report(warning) // conditional warnings that are not enabled are not fatal
57+
case _ =>
58+
reporter.report(warning.toError)
59+
}
5460
else reporter.report(warning)
5561
}
5662

5763
def deprecationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit =
58-
if (this.settings.deprecation.value) reportWarning(new DeprecationWarning(msg, pos))
64+
reportWarning(new DeprecationWarning(msg, pos))
5965

6066
def migrationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit =
6167
reportWarning(new MigrationWarning(msg, pos))

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class CompilationTests extends ParallelTesting {
162162
compileFile("tests/neg-custom-args/i3882.scala", allowDeepSubtypes) +
163163
compileFile("tests/neg-custom-args/i4372.scala", allowDeepSubtypes) +
164164
compileFile("tests/neg-custom-args/i1754.scala", allowDeepSubtypes) +
165+
compileFile("tests/neg-custom-args/conditionalWarnings.scala", allowDeepSubtypes.and("-deprecation").and("-Xfatal-warnings")) +
165166
compileFilesInDir("tests/neg-custom-args/isInstanceOf", allowDeepSubtypes and "-Xfatal-warnings") +
166167
compileFile("tests/neg-custom-args/i3627.scala", allowDeepSubtypes) +
167168
compileFile("tests/neg-custom-args/matchtype-loop.scala", allowDeepSubtypes) +
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
// run with -deprecation -Xfatal-warnings
3+
object Test {
4+
@deprecated def foo = ???
5+
6+
implied for Conversion[String, Int] = _.length
7+
8+
foo // error
9+
10+
val x: Int = "abc"
11+
// OK, since -feature warnings are not enabled.
12+
// The program compiles with final line
13+
// there were 1 feature warning(s); re-run with -feature for details
14+
}

0 commit comments

Comments
 (0)