@@ -789,7 +789,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
789789 def tryNamedTupleSelection () =
790790 val namedTupleElems = qual.tpe.widenDealias.namedTupleElementTypes
791791 val nameIdx = namedTupleElems.indexWhere(_._1 == selName)
792- if nameIdx >= 0 && sourceVersion.isAtLeast(`3.6` ) then
792+ if nameIdx >= 0 && Feature .enabled( Feature .namedTuples ) then
793793 typed(
794794 untpd.Apply (
795795 untpd.Select (untpd.TypedSplice (qual), nme.apply),
@@ -3394,7 +3394,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
33943394 /** Translate tuples of all arities */
33953395 def typedTuple (tree : untpd.Tuple , pt : Type )(using Context ): Tree =
33963396 val tree1 = desugar.tuple(tree, pt)
3397- checkAmbiguousNamedTupleAssignment (tree)
3397+ checkDeprecatedAssignmentSyntax (tree)
33983398 if tree1 ne tree then typed(tree1, pt)
33993399 else
34003400 val arity = tree.trees.length
@@ -3423,15 +3423,18 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
34233423 /** Checks if `tree` is a named tuple with one element that could be
34243424 * interpreted as an assignment, such as `(x = 1)`. If so, issues a warning.
34253425 */
3426- def checkAmbiguousNamedTupleAssignment (tree : untpd.Tuple )(using Context ): Unit =
3426+ def checkDeprecatedAssignmentSyntax (tree : untpd.Tuple )(using Context ): Unit =
34273427 tree.trees match
34283428 case List (NamedArg (name, value)) =>
34293429 val tmpCtx = ctx.fresh.setNewTyperState()
34303430 typedAssign(untpd.Assign (untpd.Ident (name), value), WildcardType )(using tmpCtx)
34313431 if ! tmpCtx.reporter.hasErrors then
34323432 // If there are no errors typing the above, then the named tuple is
34333433 // ambiguous and we issue a warning.
3434- report.migrationWarning(AmbiguousNamedTupleAssignment (name, value), tree.srcPos)
3434+ report.migrationWarning(DeprecatedAssignmentSyntax (name, value), tree.srcPos)
3435+ if MigrationVersion .AmbiguousNamedTupleSyntax .needsPatch then
3436+ patch(tree.source, Span (tree.span.start, tree.span.start + 1 ), " {" )
3437+ patch(tree.source, Span (tree.span.end - 1 , tree.span.end), " }" )
34353438 case _ => ()
34363439
34373440 /** Retrieve symbol attached to given tree */
0 commit comments