File tree Expand file tree Collapse file tree 4 files changed +29
-6
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 4 files changed +29
-6
lines changed Original file line number Diff line number Diff line change @@ -1054,14 +1054,17 @@ object Parsers {
10541054 else {
10551055 val opInfo = opStack.head
10561056 val opPrec = precedence(opInfo.operator.name)
1057- if ( prec < opPrec || leftAssoc && prec == opPrec) {
1057+ if prec < opPrec || leftAssoc && prec == opPrec then
10581058 opStack = opStack.tail
1059- recur {
1060- atSpan(opInfo.operator.span union opInfo.operand.span union top.span) {
1059+ recur :
1060+ atSpan(opInfo.operator.span union opInfo.operand.span union top.span):
1061+ def deprecateInfixNamedArg (t : Tree ): Unit = t match
1062+ case Tuple (ts) => ts.foreach(deprecateInfixNamedArg)
1063+ case Parens (t) => deprecateInfixNamedArg(t)
1064+ case t : Assign => report.deprecationWarning(InfixNamedArgDeprecation (), t.srcPos)
1065+ case _ =>
1066+ deprecateInfixNamedArg(top)
10611067 InfixOp (opInfo.operand, opInfo.operator, top)
1062- }
1063- }
1064- }
10651068 else top
10661069 }
10671070 recur(top)
Original file line number Diff line number Diff line change @@ -214,6 +214,10 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe
214214 case UnusedSymbolID // errorNumber: 198
215215 case TailrecNestedCallID // errorNumber: 199 - unused in LTS
216216 case FinalLocalDefID // errorNumber: 200
217+ case NonNamedArgumentInJavaAnnotationID // errorNumber: 201 - unused in LTS
218+ case QuotedTypeMissingID // errorNumber: 202 - unused in LTS
219+ case AmbiguousNamedTupleAssignmentID // errorNumber: 203 - unused in LTS
220+ case DeprecatedNamedInfixArgID // errorNumber: 204 - used ONLY in LTS
217221
218222 def errorNumber = ordinal - 1
219223
Original file line number Diff line number Diff line change @@ -3150,3 +3150,12 @@ object UnusedSymbol {
31503150 def privateMembers (using Context ): UnusedSymbol = new UnusedSymbol (i " unused private member " )
31513151 def patVars (using Context ): UnusedSymbol = new UnusedSymbol (i " unused pattern variable " )
31523152}
3153+
3154+ class InfixNamedArgDeprecation ()(using Context )
3155+ extends Message (DeprecatedNamedInfixArgID ):
3156+ def kind = MessageKind .PotentialIssue
3157+ def msg (using Context ) = " Named argument syntax is deprecated for infix application"
3158+ def explain (using Context ) =
3159+ i """ The argument will be parsed as a named tuple in future.
3160+ |
3161+ |To avoid this warning, either remove the argument names or use dotted selection. """
Original file line number Diff line number Diff line change 1+ //> using options -deprecation
2+
3+ class C {
4+ def f = 42 + (x = 1 ) // warn
5+ def multi (x : Int , y : Int ): Int = x + y
6+ def g = new C () `multi` (x = 42 , y = 27 ) // warn // warn
7+ }
You can’t perform that action at this time.
0 commit comments