From 312c3c6af5ae2c04b07d56f903f333ee4100403b Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 9 Oct 2018 17:27:16 +0200 Subject: [PATCH 1/4] Respect -deprecation flag --- compiler/src/dotty/tools/dotc/reporting/Reporter.scala | 2 +- compiler/test/dotty/tools/dotc/CompilationTests.scala | 1 + tests/neg-custom-args/deprecation/A_1.scala | 5 +++++ tests/neg-custom-args/deprecation/B_2.scala | 3 +++ tests/pos-special/fatal-warnings/deprecation.scala | 8 ++++++++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/neg-custom-args/deprecation/A_1.scala create mode 100644 tests/neg-custom-args/deprecation/B_2.scala create mode 100644 tests/pos-special/fatal-warnings/deprecation.scala diff --git a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala index 1c6c60073a9f..aa6aebe17146 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Reporter.scala @@ -50,7 +50,7 @@ trait Reporting { this: Context => } def deprecationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = - reportWarning(new DeprecationWarning(msg, pos)) + if (this.settings.deprecation.value) reportWarning(new DeprecationWarning(msg, pos)) def migrationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = reportWarning(new MigrationWarning(msg, pos)) diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 8809cdd2f90e..53285982dff2 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -146,6 +146,7 @@ class CompilationTests extends ParallelTesting { compileFilesInDir("tests/neg", defaultOptions) + compileFilesInDir("tests/neg-tailcall", defaultOptions) + compileFilesInDir("tests/neg-kind-polymorphism", defaultOptions and "-Ykind-polymorphism") + + compileDir("tests/neg-custom-args/deprecate", defaultOptions.and("-Xfatal-warnings", "-deprecation")) + compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")) + compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings) + compileDir("tests/neg-custom-args/impl-conv", defaultOptions.and("-Xfatal-warnings", "-feature")) + diff --git a/tests/neg-custom-args/deprecation/A_1.scala b/tests/neg-custom-args/deprecation/A_1.scala new file mode 100644 index 000000000000..2aeddf555165 --- /dev/null +++ b/tests/neg-custom-args/deprecation/A_1.scala @@ -0,0 +1,5 @@ +object A { + @deprecated("use bar instead of this one", "0.2.3") + def foo: String = "" + def bar: String = "" +} diff --git a/tests/neg-custom-args/deprecation/B_2.scala b/tests/neg-custom-args/deprecation/B_2.scala new file mode 100644 index 000000000000..3166d508d662 --- /dev/null +++ b/tests/neg-custom-args/deprecation/B_2.scala @@ -0,0 +1,3 @@ +class B { + A.foo // error: deprecation +} diff --git a/tests/pos-special/fatal-warnings/deprecation.scala b/tests/pos-special/fatal-warnings/deprecation.scala new file mode 100644 index 000000000000..2b24b1094c87 --- /dev/null +++ b/tests/pos-special/fatal-warnings/deprecation.scala @@ -0,0 +1,8 @@ +object A { + @deprecated("use bar instead of this one", "0.2.3") + def foo: Int = 3 +} + +object B { + A.foo +} From e74bd94f22e776e953f9b9661e67629eb966a458 Mon Sep 17 00:00:00 2001 From: Fengyun Liu Date: Tue, 9 Oct 2018 18:07:59 +0200 Subject: [PATCH 2/4] Fix typo --- compiler/test/dotty/tools/dotc/CompilationTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index 53285982dff2..dc888acef72e 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -146,7 +146,7 @@ class CompilationTests extends ParallelTesting { compileFilesInDir("tests/neg", defaultOptions) + compileFilesInDir("tests/neg-tailcall", defaultOptions) + compileFilesInDir("tests/neg-kind-polymorphism", defaultOptions and "-Ykind-polymorphism") + - compileDir("tests/neg-custom-args/deprecate", defaultOptions.and("-Xfatal-warnings", "-deprecation")) + + compileDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")) + compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")) + compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings) + compileDir("tests/neg-custom-args/impl-conv", defaultOptions.and("-Xfatal-warnings", "-feature")) + From 0a43005e93768246f3d38bd8839fc24d08da8f17 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 9 Oct 2018 23:05:07 +0200 Subject: [PATCH 3/4] Fix CI --- compiler/test/dotty/tools/dotc/CompilationTests.scala | 2 +- tests/neg-custom-args/deprecation/A_1.scala | 5 ----- tests/neg-custom-args/deprecation/B_2.scala | 3 --- .../{fatal-warnings => deprecation}/i2333.scala | 0 .../{fatal-warnings => deprecation}/structural.scala | 0 .../{fatal-warnings => deprecation}/t3235-minimal.scala | 0 6 files changed, 1 insertion(+), 9 deletions(-) delete mode 100644 tests/neg-custom-args/deprecation/A_1.scala delete mode 100644 tests/neg-custom-args/deprecation/B_2.scala rename tests/neg-custom-args/{fatal-warnings => deprecation}/i2333.scala (100%) rename tests/neg-custom-args/{fatal-warnings => deprecation}/structural.scala (100%) rename tests/neg-custom-args/{fatal-warnings => deprecation}/t3235-minimal.scala (100%) diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index dc888acef72e..566b6bcbf4cb 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -146,7 +146,7 @@ class CompilationTests extends ParallelTesting { compileFilesInDir("tests/neg", defaultOptions) + compileFilesInDir("tests/neg-tailcall", defaultOptions) + compileFilesInDir("tests/neg-kind-polymorphism", defaultOptions and "-Ykind-polymorphism") + - compileDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")) + + compileFilesInDir("tests/neg-custom-args/deprecation", defaultOptions.and("-Xfatal-warnings", "-deprecation")) + compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")) + compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings) + compileDir("tests/neg-custom-args/impl-conv", defaultOptions.and("-Xfatal-warnings", "-feature")) + diff --git a/tests/neg-custom-args/deprecation/A_1.scala b/tests/neg-custom-args/deprecation/A_1.scala deleted file mode 100644 index 2aeddf555165..000000000000 --- a/tests/neg-custom-args/deprecation/A_1.scala +++ /dev/null @@ -1,5 +0,0 @@ -object A { - @deprecated("use bar instead of this one", "0.2.3") - def foo: String = "" - def bar: String = "" -} diff --git a/tests/neg-custom-args/deprecation/B_2.scala b/tests/neg-custom-args/deprecation/B_2.scala deleted file mode 100644 index 3166d508d662..000000000000 --- a/tests/neg-custom-args/deprecation/B_2.scala +++ /dev/null @@ -1,3 +0,0 @@ -class B { - A.foo // error: deprecation -} diff --git a/tests/neg-custom-args/fatal-warnings/i2333.scala b/tests/neg-custom-args/deprecation/i2333.scala similarity index 100% rename from tests/neg-custom-args/fatal-warnings/i2333.scala rename to tests/neg-custom-args/deprecation/i2333.scala diff --git a/tests/neg-custom-args/fatal-warnings/structural.scala b/tests/neg-custom-args/deprecation/structural.scala similarity index 100% rename from tests/neg-custom-args/fatal-warnings/structural.scala rename to tests/neg-custom-args/deprecation/structural.scala diff --git a/tests/neg-custom-args/fatal-warnings/t3235-minimal.scala b/tests/neg-custom-args/deprecation/t3235-minimal.scala similarity index 100% rename from tests/neg-custom-args/fatal-warnings/t3235-minimal.scala rename to tests/neg-custom-args/deprecation/t3235-minimal.scala From b5fe9858f298c07d1c31647d0c6e28c9ec9b5169 Mon Sep 17 00:00:00 2001 From: Liu Fengyun Date: Tue, 9 Oct 2018 23:20:47 +0200 Subject: [PATCH 4/4] Emit language deprecated feature as normal warnings --- compiler/src/dotty/tools/dotc/typer/Checking.scala | 2 +- .../{deprecation => fatal-warnings}/structural.scala | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/neg-custom-args/{deprecation => fatal-warnings}/structural.scala (100%) diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index a853965ea1bf..a85f92bcf43b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -288,7 +288,7 @@ object Checking { def checkRefinementNonCyclic(refinement: Tree, refineCls: ClassSymbol, seen: mutable.Set[Symbol]) (implicit ctx: Context): Unit = { def flag(what: String, tree: Tree) = - ctx.deprecationWarning(i"$what reference in refinement is deprecated", tree.pos) + ctx.warning(i"$what reference in refinement is deprecated", tree.pos) def forwardRef(tree: Tree) = flag("forward", tree) def selfRef(tree: Tree) = flag("self", tree) val checkTree = new TreeAccumulator[Unit] { diff --git a/tests/neg-custom-args/deprecation/structural.scala b/tests/neg-custom-args/fatal-warnings/structural.scala similarity index 100% rename from tests/neg-custom-args/deprecation/structural.scala rename to tests/neg-custom-args/fatal-warnings/structural.scala