Skip to content

Commit 83882eb

Browse files
committed
Fix #2333: Check if class is deprecated
1 parent f595a1a commit 83882eb

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,11 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
257257
case tree: MemberDef =>
258258
transformMemberDef(tree)
259259
super.transform(tree)
260-
case tree: New if isCheckable(tree) =>
261-
Checking.checkInstantiable(tree.tpe, tree.pos)
260+
case tree: New =>
261+
if (tree.tpe.classSymbol.hasAnnotation(defn.DeprecatedAnnot))
262+
ctx.deprecationWarning(s"${tree.tpe.typeSymbol} is deprecated", tree.pos)
263+
if (isCheckable(tree))
264+
Checking.checkInstantiable(tree.tpe, tree.pos)
262265
super.transform(tree)
263266
case tree @ Annotated(annotated, annot) =>
264267
cpy.Annotated(tree)(transform(annotated), transformAnnot(annot))

tests/neg-custom-args/i2333.scala

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

0 commit comments

Comments
 (0)