@@ -789,7 +789,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
789
789
def tryNamedTupleSelection () =
790
790
val namedTupleElems = qual.tpe.widenDealias.namedTupleElementTypes
791
791
val nameIdx = namedTupleElems.indexWhere(_._1 == selName)
792
- if nameIdx >= 0 && sourceVersion.isAtLeast(`3.6` ) then
792
+ if nameIdx >= 0 && Feature .enabled( Feature .namedTuples ) then
793
793
typed(
794
794
untpd.Apply (
795
795
untpd.Select (untpd.TypedSplice (qual), nme.apply),
@@ -3394,7 +3394,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3394
3394
/** Translate tuples of all arities */
3395
3395
def typedTuple (tree : untpd.Tuple , pt : Type )(using Context ): Tree =
3396
3396
val tree1 = desugar.tuple(tree, pt)
3397
- checkAmbiguousNamedTupleAssignment (tree)
3397
+ checkDeprecatedAssignmentSyntax (tree)
3398
3398
if tree1 ne tree then typed(tree1, pt)
3399
3399
else
3400
3400
val arity = tree.trees.length
@@ -3423,15 +3423,18 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3423
3423
/** Checks if `tree` is a named tuple with one element that could be
3424
3424
* interpreted as an assignment, such as `(x = 1)`. If so, issues a warning.
3425
3425
*/
3426
- def checkAmbiguousNamedTupleAssignment (tree : untpd.Tuple )(using Context ): Unit =
3426
+ def checkDeprecatedAssignmentSyntax (tree : untpd.Tuple )(using Context ): Unit =
3427
3427
tree.trees match
3428
3428
case List (NamedArg (name, value)) =>
3429
3429
val tmpCtx = ctx.fresh.setNewTyperState()
3430
3430
typedAssign(untpd.Assign (untpd.Ident (name), value), WildcardType )(using tmpCtx)
3431
3431
if ! tmpCtx.reporter.hasErrors then
3432
3432
// If there are no errors typing the above, then the named tuple is
3433
3433
// 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), " }" )
3435
3438
case _ => ()
3436
3439
3437
3440
/** Retrieve symbol attached to given tree */
0 commit comments