@@ -1137,15 +1137,39 @@ object Parsers {
1137
1137
if (prec < opPrec || leftAssoc && prec == opPrec) {
1138
1138
opStack = opStack.tail
1139
1139
recur {
1140
- atSpan(opInfo.operator.span union opInfo.operand.span union top.span):
1141
- InfixOp (opInfo.operand, opInfo.operator, top)
1140
+ migrateInfixOp(opInfo, isType):
1141
+ atSpan(opInfo.operator.span union opInfo.operand.span union top.span):
1142
+ InfixOp (opInfo.operand, opInfo.operator, top)
1142
1143
}
1143
1144
}
1144
1145
else top
1145
1146
}
1146
1147
recur(top)
1147
1148
}
1148
1149
1150
+ private def migrateInfixOp (opInfo : OpInfo , isType : Boolean )(infixOp : InfixOp ): Tree = {
1151
+ def isNamedTupleOperator = opInfo.operator.name match
1152
+ case nme.EQ | nme.NE | nme.eq | nme.ne | nme.`++` | nme.zip => true
1153
+ case _ => false
1154
+ if isType then infixOp
1155
+ else infixOp.right match
1156
+ case Tuple (args) if args.exists(_.isInstanceOf [NamedArg ]) && ! isNamedTupleOperator =>
1157
+ report.errorOrMigrationWarning(DeprecatedInfixNamedArgumentSyntax (), infixOp.right.srcPos, MigrationVersion .AmbiguousNamedTupleSyntax )
1158
+ if MigrationVersion .AmbiguousNamedTupleSyntax .needsPatch then
1159
+ val asApply = cpy.Apply (infixOp)(Select (opInfo.operand, opInfo.operator.name), args)
1160
+ patch(source, infixOp.span, asApply.show(using ctx.withoutColors))
1161
+ asApply // allow to use pre-3.6 syntax in migration mode
1162
+ else infixOp
1163
+ case Parens (assign @ Assign (ident, value)) if ! isNamedTupleOperator =>
1164
+ report.errorOrMigrationWarning(DeprecatedInfixNamedArgumentSyntax (), infixOp.right.srcPos, MigrationVersion .AmbiguousNamedTupleSyntax )
1165
+ if MigrationVersion .AmbiguousNamedTupleSyntax .needsPatch then
1166
+ val asApply = cpy.Apply (infixOp)(Select (opInfo.operand, opInfo.operator.name), assign :: Nil )
1167
+ patch(source, infixOp.span, asApply.show(using ctx.withoutColors))
1168
+ asApply // allow to use pre-3.6 syntax in migration mode
1169
+ else infixOp
1170
+ case _ => infixOp
1171
+ }
1172
+
1149
1173
/** True if we are seeing a lambda argument after a colon of the form:
1150
1174
* : (params) =>
1151
1175
* body
0 commit comments