Skip to content

Commit 3a7ce75

Browse files
committed
Don't eagerly strip NamedArgs
1 parent cc9dfe6 commit 3a7ce75

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

compiler/src/dotty/tools/dotc/ast/TreeInfo.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,16 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
142142

143143
/** All term arguments of an application in a single flattened list */
144144
def allTermArguments(tree: Tree): List[Tree] = unsplice(tree) match {
145-
case Apply(fn, args) => allTermArguments(fn) ::: args.map(stripNamedArg)
145+
case Apply(fn, args) => allTermArguments(fn) ::: args
146146
case TypeApply(fn, args) => allTermArguments(fn)
147147
case Block(Nil, expr) => allTermArguments(expr)
148148
case _ => Nil
149149
}
150150

151151
/** All type and term arguments of an application in a single flattened list */
152152
def allArguments(tree: Tree): List[Tree] = unsplice(tree) match {
153-
case Apply(fn, args) => allArguments(fn) ::: args.map(stripNamedArg)
154-
case TypeApply(fn, args) => allArguments(fn) ::: args.map(stripNamedArg)
153+
case Apply(fn, args) => allArguments(fn) ::: args
154+
case TypeApply(fn, args) => allArguments(fn) ::: args
155155
case Block(Nil, expr) => allArguments(expr)
156156
case _ => Nil
157157
}

compiler/src/dotty/tools/dotc/cc/CaptureOps.scala

+7-8
Original file line numberDiff line numberDiff line change
@@ -160,14 +160,13 @@ extension (tree: Tree)
160160
refs
161161

162162
/** The arguments of a @retains, @retainsCap or @retainsByName annotation */
163-
def retainedElems(using Context): List[Tree] =
164-
tpd.allTermArguments(tree) match
165-
case List(Typed(SeqLiteral(elems, _), _)) =>
166-
elems
167-
case _ =>
168-
if tree.symbol.maybeOwner == defn.RetainsCapAnnot
169-
then ref(defn.captureRoot.termRef) :: Nil
170-
else Nil
163+
def retainedElems(using Context): List[Tree] = tree match
164+
case Apply(_, Typed(SeqLiteral(elems, _), _) :: Nil) =>
165+
elems
166+
case _ =>
167+
if tree.symbol.maybeOwner == defn.RetainsCapAnnot
168+
then ref(defn.captureRoot.termRef) :: Nil
169+
else Nil
171170

172171
extension (tp: Type)
173172

0 commit comments

Comments
 (0)