File tree Expand file tree Collapse file tree 4 files changed +23
-0
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +23
-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,17 @@ 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 paramSymss = tree.symbol.paramSymss.flatten
180+ for namedArg <- tree.args.filterConserve(isNamedArg).asInstanceOf [List [NamedArg ]]
181+ name = namedArg.name
182+ // We will have at most one parameter (we have 0 if the parameter name changed with a refined type)
183+ sym <- paramSymss.filter(_.name == name)
184+ annot <- sym.getAnnotation(defn.DeprecatedNameAnnot )
185+ do
186+ report.deprecationWarning(em " naming parameter $name is deprecated " , namedArg.srcPos)
187+ ctx
188+
177189 override def transformApply (tree : Apply )(using Context ): Tree =
178190 constToLiteral(foldCondition(tree))
179191
Original file line number Diff line number Diff line change 1+ -- Deprecation Warning: tests/warn/i19077.scala:6:6 --------------------------------------------------------------------
2+ 6 | f(x = 2) // warn
3+ | ^^^^^
4+ | naming parameter x is deprecated
Original file line number Diff line number Diff line change 1+ //> using options -deprecation
2+
3+ def f (@ deprecatedName x : Int ) = x * 2
4+
5+ @ main def Test =
6+ f(x = 2 ) // warn
You can’t perform that action at this time.
0 commit comments