From f18b5f633cbe2bf7b72e761834ad7b9971643fbf Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 19 Apr 2019 14:02:09 +0200 Subject: [PATCH 1/3] Revert deprecation warnings disable Deprecation warnings did not print a "There were deprecation warnings" anymore. This invalidates the whole point of making them deprecation warnings in the first place! --- compiler/src/dotty/tools/dotc/reporting/Reporter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index f03e39963663..0926910f705e 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -55,7 +55,7 @@ trait Reporting { this: Context => } def deprecationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - if (this.settings.deprecation.value) reportWarning(new DeprecationWarning(msg, pos)) + reportWarning(new DeprecationWarning(msg, pos)) def migrationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = reportWarning(new MigrationWarning(msg, pos)) From 717fec4556d2781b5742735698df801d4ae3b574 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 19 Apr 2019 14:26:49 +0200 Subject: [PATCH 2/3] Don't issue errors under -Xfatal-warnings for disabled conditional warnings --- compiler/src/dotty/tools/dotc/reporting/Reporter.scala | 8 +++++++- compiler/test/dotty/tools/dotc/CompilationTests.scala | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index 0926910f705e..cf5184f198b3 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -50,7 +50,13 @@ trait Reporting { this: Context => def reportWarning(warning: Warning): Unit = if (!this.settings.silentWarnings.value) { - if (this.settings.XfatalWarnings.value) reporter.report(warning.toError) + if (this.settings.XfatalWarnings.value) + warning match { + case warning: ConditionalWarning if !warning.enablingOption.value => + reporter.report(warning) // conditional warnings that are not enabled are not fatal + case _ => + reporter.report(warning.toError) + } else reporter.report(warning) } diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index c8f34726d2d0..a4a32d7ebe8b 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -162,6 +162,7 @@ class CompilationTests extends ParallelTesting { compileFile("tests/neg-custom-args/i3882.scala", allowDeepSubtypes) + compileFile("tests/neg-custom-args/i4372.scala", allowDeepSubtypes) + compileFile("tests/neg-custom-args/i1754.scala", allowDeepSubtypes) + + compileFile("tests/neg-custom-args/conditionalWarnings.scala", allowDeepSubtypes.and("-deprecation").and("-Xfatal-warnings")) + compileFilesInDir("tests/neg-custom-args/isInstanceOf", allowDeepSubtypes and "-Xfatal-warnings") + compileFile("tests/neg-custom-args/i3627.scala", allowDeepSubtypes) + compileFile("tests/neg-custom-args/matchtype-loop.scala", allowDeepSubtypes) + From dd8d03a5d58069ff602e840b4c0472ef08d7822f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 19 Apr 2019 14:50:22 +0200 Subject: [PATCH 3/3] Add test --- tests/neg-custom-args/conditionalWarnings.scala | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/neg-custom-args/conditionalWarnings.scala diff --git a/tests/neg-custom-args/conditionalWarnings.scala b/tests/neg-custom-args/conditionalWarnings.scala new file mode 100644 index 000000000000..af873dee5357 --- /dev/null +++ b/tests/neg-custom-args/conditionalWarnings.scala @@ -0,0 +1,14 @@ + +// run with -deprecation -Xfatal-warnings +object Test { + @deprecated def foo = ??? + + implied for Conversion[String, Int] = _.length + + foo // error + + val x: Int = "abc" + // OK, since -feature warnings are not enabled. + // The program compiles with final line + // there were 1 feature warning(s); re-run with -feature for details +}