Skip to content

Commit 312c3c6

Browse files
committed
Respect -deprecation flag
1 parent 7a45a4a commit 312c3c6

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ trait Reporting { this: Context =>
5050
}
5151

5252
def deprecationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit =
53-
reportWarning(new DeprecationWarning(msg, pos))
53+
if (this.settings.deprecation.value) reportWarning(new DeprecationWarning(msg, pos))
5454

5555
def migrationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit =
5656
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
@@ -146,6 +146,7 @@ class CompilationTests extends ParallelTesting {
146146
compileFilesInDir("tests/neg", defaultOptions) +
147147
compileFilesInDir("tests/neg-tailcall", defaultOptions) +
148148
compileFilesInDir("tests/neg-kind-polymorphism", defaultOptions and "-Ykind-polymorphism") +
149+
compileDir("tests/neg-custom-args/deprecate", defaultOptions.and("-Xfatal-warnings", "-deprecation")) +
149150
compileFilesInDir("tests/neg-custom-args/fatal-warnings", defaultOptions.and("-Xfatal-warnings")) +
150151
compileFilesInDir("tests/neg-custom-args/allow-double-bindings", allowDoubleBindings) +
151152
compileDir("tests/neg-custom-args/impl-conv", defaultOptions.and("-Xfatal-warnings", "-feature")) +
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object A {
2+
@deprecated("use bar instead of this one", "0.2.3")
3+
def foo: String = ""
4+
def bar: String = ""
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class B {
2+
A.foo // error: deprecation
3+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object A {
2+
@deprecated("use bar instead of this one", "0.2.3")
3+
def foo: Int = 3
4+
}
5+
6+
object B {
7+
A.foo
8+
}

0 commit comments

Comments
 (0)