Skip to content

Commit

Permalink
Restore previous behavior of Annotation.arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
mbovel committed May 22, 2024
1 parent 062492e commit 12ad085
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions compiler/src/dotty/tools/dotc/ast/TreeInfo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@ trait TreeInfo[T <: Untyped] { self: Trees.Instance[T] =>
case _ => argss
loop(tree, Nil)

/** All term arguments of an application in a single flattened list */
def allTermArguments(tree: Tree): List[Tree] = unsplice(tree) match {
case Apply(fn, args) => allArguments(fn) ::: args
case TypeApply(fn, args) => allArguments(fn)
case Block(_, expr) => allArguments(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
Expand Down
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Annotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ object Annotations {
def derivedAnnotation(tree: Tree)(using Context): Annotation =
if (tree eq this.tree) this else Annotation(tree)

/** All type and term arguments to this annotation in a single flat list */
def arguments(using Context): List[Tree] = tpd.allArguments(tree)
/** All term arguments of this annotation in a single flat list */
def arguments(using Context): List[Tree] = tpd.allTermArguments(tree)

def argument(i: Int)(using Context): Option[Tree] = {
val args = arguments
Expand All @@ -55,7 +55,7 @@ object Annotations {
* type, since ranges cannot be types of trees.
*/
def mapWith(tm: TypeMap)(using Context) =
val args = arguments
val args = tpd.allArguments(tree)
if args.isEmpty then this
else
// Checks if `tm` would result in any change by applying it to types
Expand Down

0 comments on commit 12ad085

Please sign in to comment.