Skip to content

Commit 3965690

Browse files
committed
Remove needless filter
1 parent 85bdee8 commit 3965690

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,53 +1400,53 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
14001400
lhs: Tree
14011401
)(using Context): Option[PartialAssignment[LValue]] =
14021402
/** 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]) =
14041404
lhs match
14051405
case f @ Ident(name: TermName) =>
14061406
// We need to make sure that the prefix of this extension getter is retained when we
14071407
// transform it into a setter. Otherwise, we could end up resolving an unrelated setter
14081408
// from another extension. See tests/pos/i18713.scala for an example.
14091409
f.tpe match
14101410
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)
14121412
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)
14141414
case TermRef(NoPrefix, _) =>
1415-
(untpd.cpy.Ident(f)(name.setterName), captures)
1415+
(untpd.cpy.Ident(f)(name.setterName), locals)
14161416

14171417
case f @ Select(q, name: TermName) =>
14181418
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)
14201420

14211421
case f @ TypeApply(g, ts) =>
1422-
val (s, cs) = formSetter(g, captures)
1422+
val (s, cs) = formSetter(g, locals)
14231423
(untpd.cpy.TypeApply(f)(s, ts.map((t) => untpd.TypedSplice(t))), cs)
14241424

14251425
case f @ Apply(g, as) =>
1426-
var (s, newCaptures) = formSetter(g, captures)
1426+
var (s, newLocals) = formSetter(g, locals)
14271427
var arguments = List[untpd.Tree]()
14281428
for a <- as do
14291429
val (v, d) = PossiblyHoistedValue(a).valueAndDefinition
14301430
arguments = untpd.TypedSplice(v, isExtensionReceiver = true) +: arguments
1431-
newCaptures = newCaptures ++ d
1431+
newLocals = newLocals ++ d
14321432

14331433
val setter = untpd.cpy.Apply(f)(s, arguments)
14341434

14351435
g match
14361436
case _: Apply =>
14371437
// Current apply is to implicit arguments. Note that we cannot copy the apply kind
14381438
// 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)
14401440
case _ =>
1441-
(setter, newCaptures)
1441+
(setter, newLocals)
14421442

14431443
case _ =>
14441444
(EmptyTree, List())
14451445

1446-
val (setter, captures) = formSetter(lhs, List())
1446+
val (setter, locals) = formSetter(lhs, List())
14471447
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) })
14501450

14511451
def typedAssign(tree: untpd.Assign, pt: Type)(using Context): Tree =
14521452
tree.lhs match

0 commit comments

Comments
 (0)