File tree 4 files changed +22
-0
lines changed
compiler/src/dotty/tools/dotc
4 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1006,6 +1006,7 @@ class Definitions {
1006
1006
@ tu lazy val ProvisionalSuperClassAnnot : ClassSymbol = requiredClass(" scala.annotation.internal.ProvisionalSuperClass" )
1007
1007
@ tu lazy val DeprecatedAnnot : ClassSymbol = requiredClass(" scala.deprecated" )
1008
1008
@ tu lazy val DeprecatedOverridingAnnot : ClassSymbol = requiredClass(" scala.deprecatedOverriding" )
1009
+ @ tu lazy val DeprecatedNameAnnot : ClassSymbol = requiredClass(" scala.deprecatedName" )
1009
1010
@ tu lazy val ImplicitAmbiguousAnnot : ClassSymbol = requiredClass(" scala.annotation.implicitAmbiguous" )
1010
1011
@ tu lazy val ImplicitNotFoundAnnot : ClassSymbol = requiredClass(" scala.annotation.implicitNotFound" )
1011
1012
@ 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,18 @@ 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 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
+
177
190
override def transformApply (tree : Apply )(using Context ): Tree =
178
191
constToLiteral(foldCondition(tree))
179
192
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