@@ -792,7 +792,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
792792 def tryNamedTupleSelection () =
793793 val namedTupleElems = qual.tpe.widenDealias.namedTupleElementTypes
794794 val nameIdx = namedTupleElems.indexWhere(_._1 == selName)
795- if nameIdx >= 0 && sourceVersion.isAtLeast(`3.6` ) then
795+ if nameIdx >= 0 && Feature .enabled( Feature .namedTuples ) then
796796 typed(
797797 untpd.Apply (
798798 untpd.Select (untpd.TypedSplice (qual), nme.apply),
@@ -3398,7 +3398,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
33983398 /** Translate tuples of all arities */
33993399 def typedTuple (tree : untpd.Tuple , pt : Type )(using Context ): Tree =
34003400 val tree1 = desugar.tuple(tree, pt)
3401- checkAmbiguousNamedTupleAssignment (tree)
3401+ checkDeprecatedAssignmentSyntax (tree)
34023402 if tree1 ne tree then typed(tree1, pt)
34033403 else
34043404 val arity = tree.trees.length
@@ -3427,15 +3427,18 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
34273427 /** Checks if `tree` is a named tuple with one element that could be
34283428 * interpreted as an assignment, such as `(x = 1)`. If so, issues a warning.
34293429 */
3430- def checkAmbiguousNamedTupleAssignment (tree : untpd.Tuple )(using Context ): Unit =
3430+ def checkDeprecatedAssignmentSyntax (tree : untpd.Tuple )(using Context ): Unit =
34313431 tree.trees match
34323432 case List (NamedArg (name, value)) =>
34333433 val tmpCtx = ctx.fresh.setNewTyperState()
34343434 typedAssign(untpd.Assign (untpd.Ident (name), value), WildcardType )(using tmpCtx)
34353435 if ! tmpCtx.reporter.hasErrors then
34363436 // If there are no errors typing the above, then the named tuple is
34373437 // ambiguous and we issue a warning.
3438- report.migrationWarning(AmbiguousNamedTupleAssignment (name, value), tree.srcPos)
3438+ report.migrationWarning(DeprecatedAssignmentSyntax (name, value), tree.srcPos)
3439+ if MigrationVersion .AmbiguousNamedTupleSyntax .needsPatch then
3440+ patch(tree.source, Span (tree.span.start, tree.span.start + 1 ), " {" )
3441+ patch(tree.source, Span (tree.span.end - 1 , tree.span.end), " }" )
34393442 case _ => ()
34403443
34413444 /** Retrieve symbol attached to given tree */
0 commit comments