@@ -1400,53 +1400,53 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
1400
1400
lhs : Tree
1401
1401
)(using Context ): Option [PartialAssignment [LValue ]] =
1402
1402
/** Returns the setter corresponding to `lhs`, which is a getter, along hoisted definitions. */
1403
- def formSetter (lhs : Tree , captures : List [Tree ]): (untpd.Tree , List [Tree ]) =
1403
+ def formSetter (lhs : Tree , locals : List [ValDef ]): (untpd.Tree , List [ValDef ]) =
1404
1404
lhs match
1405
1405
case f @ Ident (name : TermName ) =>
1406
1406
// We need to make sure that the prefix of this extension getter is retained when we
1407
1407
// transform it into a setter. Otherwise, we could end up resolving an unrelated setter
1408
1408
// from another extension. See tests/pos/i18713.scala for an example.
1409
1409
f.tpe match
1410
1410
case TermRef (q : TermRef , _) =>
1411
- formSetter(ref(q).select(f.symbol).withSpan(f.span), captures )
1411
+ formSetter(ref(q).select(f.symbol).withSpan(f.span), locals )
1412
1412
case TermRef (q : ThisType , _) =>
1413
- formSetter(This (q.cls).select(f.symbol).withSpan(f.span), captures )
1413
+ formSetter(This (q.cls).select(f.symbol).withSpan(f.span), locals )
1414
1414
case TermRef (NoPrefix , _) =>
1415
- (untpd.cpy.Ident (f)(name.setterName), captures )
1415
+ (untpd.cpy.Ident (f)(name.setterName), locals )
1416
1416
1417
1417
case f @ Select (q, name : TermName ) =>
1418
1418
val (v, d) = PossiblyHoistedValue (q).valueAndDefinition
1419
- (untpd.cpy.Select (f)(untpd.TypedSplice (v), name.setterName), captures ++ d)
1419
+ (untpd.cpy.Select (f)(untpd.TypedSplice (v), name.setterName), locals ++ d)
1420
1420
1421
1421
case f @ TypeApply (g, ts) =>
1422
- val (s, cs) = formSetter(g, captures )
1422
+ val (s, cs) = formSetter(g, locals )
1423
1423
(untpd.cpy.TypeApply (f)(s, ts.map((t) => untpd.TypedSplice (t))), cs)
1424
1424
1425
1425
case f @ Apply (g, as) =>
1426
- var (s, newCaptures ) = formSetter(g, captures )
1426
+ var (s, newLocals ) = formSetter(g, locals )
1427
1427
var arguments = List [untpd.Tree ]()
1428
1428
for a <- as do
1429
1429
val (v, d) = PossiblyHoistedValue (a).valueAndDefinition
1430
1430
arguments = untpd.TypedSplice (v, isExtensionReceiver = true ) +: arguments
1431
- newCaptures = newCaptures ++ d
1431
+ newLocals = newLocals ++ d
1432
1432
1433
1433
val setter = untpd.cpy.Apply (f)(s, arguments)
1434
1434
1435
1435
g match
1436
1436
case _ : Apply =>
1437
1437
// Current apply is to implicit arguments. Note that we cannot copy the apply kind
1438
1438
// of `f` since `f` is a typed tree and apply kinds are not preserved for those.
1439
- (setter.setApplyKind(ApplyKind .Using ), newCaptures )
1439
+ (setter.setApplyKind(ApplyKind .Using ), newLocals )
1440
1440
case _ =>
1441
- (setter, newCaptures )
1441
+ (setter, newLocals )
1442
1442
1443
1443
case _ =>
1444
1444
(EmptyTree , List ())
1445
1445
1446
- val (setter, captures ) = formSetter(lhs, List ())
1446
+ val (setter, locals ) = formSetter(lhs, List ())
1447
1447
if setter.isEmpty then None else
1448
- val cs = captures.collect { case d : tpd. ValDef => d }
1449
- Some (PartialAssignment (UnappliedSetter (setter, cs) ) { (l, r) => l.formAssignment(r) })
1448
+ val lvalue = ApplyLValue ( ApplyLValue . Callee . Untyped (setter, locals), List ())
1449
+ Some (PartialAssignment (lvalue ) { (l, r) => l.formAssignment(r) })
1450
1450
1451
1451
def typedAssign (tree : untpd.Assign , pt : Type )(using Context ): Tree =
1452
1452
tree.lhs match
0 commit comments