Skip to content

Commit

Permalink
Don't eagerly strip NamedArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbovel committed Nov 27, 2024
1 parent cc9dfe6 commit 3a7ce75
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -142,16 +142,16 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>

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

/** All type and term arguments of an application in a single flattened list */
def allArguments(tree: Tree): List[Tree] = unsplice(tree) match {
case Apply(fn, args) => allArguments(fn) ::: args.map(stripNamedArg)
case TypeApply(fn, args) => allArguments(fn) ::: args.map(stripNamedArg)
case Apply(fn, args) => allArguments(fn) ::: args
case TypeApply(fn, args) => allArguments(fn) ::: args
case Block(Nil, expr) => allArguments(expr)
case _ => Nil
}
Expand Down
15 changes: 7 additions & 8 deletions compiler/src/dotty/tools/dotc/cc/CaptureOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,13 @@ extension (tree: Tree)
refs

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

extension (tp: Type)

Expand Down

0 comments on commit 3a7ce75

Please sign in to comment.