File tree Expand file tree Collapse file tree 4 files changed +22
-0
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1006,6 +1006,7 @@ class Definitions {
10061006 @ tu lazy val ProvisionalSuperClassAnnot : ClassSymbol = requiredClass(" scala.annotation.internal.ProvisionalSuperClass" )
10071007 @ tu lazy val DeprecatedAnnot : ClassSymbol = requiredClass(" scala.deprecated" )
10081008 @ tu lazy val DeprecatedOverridingAnnot : ClassSymbol = requiredClass(" scala.deprecatedOverriding" )
1009+ @ tu lazy val DeprecatedNameAnnot : ClassSymbol = requiredClass(" scala.deprecatedName" )
10091010 @ tu lazy val ImplicitAmbiguousAnnot : ClassSymbol = requiredClass(" scala.annotation.implicitAmbiguous" )
10101011 @ tu lazy val ImplicitNotFoundAnnot : ClassSymbol = requiredClass(" scala.annotation.implicitNotFound" )
10111012 @ tu lazy val InlineParamAnnot : ClassSymbol = requiredClass(" scala.annotation.internal.InlineParam" )
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import core.*
55import Names .*
66import dotty .tools .dotc .transform .MegaPhase .*
77import ast .untpd
8+ import ast .tpd
89import Flags .*
910import Types .*
1011import Constants .Constant
@@ -174,6 +175,18 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
174175 override def transformTypeApply (tree : TypeApply )(using Context ): Tree =
175176 constToLiteral(tree)
176177
178+ override def prepareForApply (tree : tpd.Apply )(using Context ): Context =
179+ val namedArgs = tree.args.filterConserve(isNamedArg).asInstanceOf [List [NamedArg ]]
180+ val paramSymss = tree.symbol.paramSymss.flatten
181+ for namedArg <- namedArgs do
182+ val name = namedArg.name
183+ val sym = paramSymss.filter(_.name == name).head
184+ sym.getAnnotation(defn.DeprecatedNameAnnot ) match
185+ case Some (annot) =>
186+ report.warning(em " naming parameter $name is deprecated " , namedArg.srcPos)
187+ case None =>
188+ ctx
189+
177190 override def transformApply (tree : Apply )(using Context ): Tree =
178191 constToLiteral(foldCondition(tree))
179192
Original file line number Diff line number Diff line change 1+ -- Warning: tests/warn/i19077.scala:4:21 -------------------------------------------------------------------------------
2+ 4 |@main def Test = f(x = 2) // warn
3+ | ^^^^^
4+ | naming parameter x is deprecated
Original file line number Diff line number Diff line change 1+
2+ def f (@ deprecatedName x : Int ) = x * 2
3+
4+ @ main def Test = f(x = 2 ) // warn
You can’t perform that action at this time.
0 commit comments