@@ -1137,15 +1137,39 @@ object Parsers {
11371137 if (prec < opPrec || leftAssoc && prec == opPrec) {
11381138 opStack = opStack.tail
11391139 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)
11421143 }
11431144 }
11441145 else top
11451146 }
11461147 recur(top)
11471148 }
11481149
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+
11491173 /** True if we are seeing a lambda argument after a colon of the form:
11501174 * : (params) =>
11511175 * body
0 commit comments