File tree 4 files changed +23
-0
lines changed
compiler/src/dotty/tools/dotc
4 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -1011,6 +1011,7 @@ class Definitions {
1011
1011
@ tu lazy val DeprecatedAnnot : ClassSymbol = requiredClass(" scala.deprecated" )
1012
1012
@ tu lazy val DeprecatedOverridingAnnot : ClassSymbol = requiredClass(" scala.deprecatedOverriding" )
1013
1013
@ tu lazy val DeprecatedInheritanceAnnot : ClassSymbol = requiredClass(" scala.deprecatedInheritance" )
1014
+ @ tu lazy val DeprecatedNameAnnot : ClassSymbol = requiredClass(" scala.deprecatedName" )
1014
1015
@ tu lazy val ImplicitAmbiguousAnnot : ClassSymbol = requiredClass(" scala.annotation.implicitAmbiguous" )
1015
1016
@ tu lazy val ImplicitNotFoundAnnot : ClassSymbol = requiredClass(" scala.annotation.implicitNotFound" )
1016
1017
@ 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.*
5
5
import Names .*
6
6
import dotty .tools .dotc .transform .MegaPhase .*
7
7
import ast .untpd
8
+ import ast .tpd
8
9
import Flags .*
9
10
import Types .*
10
11
import Constants .Constant
@@ -174,6 +175,17 @@ class FirstTransform extends MiniPhase with InfoTransformer { thisPhase =>
174
175
override def transformTypeApply (tree : TypeApply )(using Context ): Tree =
175
176
constToLiteral(tree)
176
177
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
+
177
189
override def transformApply (tree : Apply )(using Context ): Tree =
178
190
constToLiteral(foldCondition(tree))
179
191
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