Skip to content

Commit 82dd280

Browse files
Merge pull request #3811 from dotty-staging/fix-#2333
Fix #2333: Check if class is deprecated
2 parents fc983f7 + 6129ac5 commit 82dd280

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -879,7 +879,9 @@ class RefChecks extends MiniPhase { thisPhase =>
879879
}
880880

881881
override def transformNew(tree: New)(implicit ctx: Context) = {
882-
currentLevel.enterReference(tree.tpe.typeSymbol, tree.pos)
882+
val sym = tree.tpe.typeSymbol
883+
checkUndesiredProperties(sym, tree.pos)
884+
currentLevel.enterReference(sym, tree.pos)
883885
tree
884886
}
885887
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ class CompilationTests extends ParallelTesting {
186186
compileFile("../tests/neg-custom-args/xfatalWarnings.scala", defaultOptions.and("-Xfatal-warnings")) +
187187
compileFile("../tests/neg-custom-args/pureStatement.scala", defaultOptions.and("-Xfatal-warnings")) +
188188
compileFile("../tests/neg-custom-args/i3589-a.scala", defaultOptions.and("-Xfatal-warnings")) +
189+
compileFile("../tests/neg-custom-args/i2333.scala", defaultOptions.and("-Xfatal-warnings")) +
189190
compileFile("../tests/neg-custom-args/phantom-overload.scala", allowDoubleBindings) +
190191
compileFile("../tests/neg-custom-args/phantom-overload-2.scala", allowDoubleBindings) +
191192
compileFile("../tests/neg-custom-args/structural.scala", defaultOptions.and("-Xfatal-warnings"))

tests/neg-custom-args/i2333.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@deprecated("bla", "2.11.0") class Foo {
2+
def this(x: Int) = this()
3+
}
4+
5+
object Test {
6+
new Foo // error: deprecated
7+
new Foo(1) // error: deprecated
8+
}

0 commit comments

Comments
 (0)