Skip to content

Commit e7af2b2

Browse files
Merge pull request #5225 from dotty-staging/fix-deprecation
Respect -deprecation flag
2 parents 863d944 + b5fe985 commit e7af2b2

File tree

6 files changed

+11
-2
lines changed

6 files changed

+11
-2
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/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ object Checking {
288288
def checkRefinementNonCyclic(refinement: Tree, refineCls: ClassSymbol, seen: mutable.Set[Symbol])
289289
(implicit ctx: Context): Unit = {
290290
def flag(what: String, tree: Tree) =
291-
ctx.deprecationWarning(i"$what reference in refinement is deprecated", tree.pos)
291+
ctx.warning(i"$what reference in refinement is deprecated", tree.pos)
292292
def forwardRef(tree: Tree) = flag("forward", tree)
293293
def selfRef(tree: Tree) = flag("self", tree)
294294
val checkTree = new TreeAccumulator[Unit] {

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+
compileFilesInDir("tests/neg-custom-args/deprecation", 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: 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)