@@ -621,24 +621,38 @@ trait TypedTreeInfo extends TreeInfo[Type] { self: Trees.Instance[Type] =>
621621 }
622622 }
623623
624- /** Decompose a call fn[targs](vargs_1)...(vargs_n)
625- * into its constituents (fn, targs, vargss).
626- *
627- * Note: targ and vargss may be empty
628- */
629- def decomposeCall (tree : Tree ): (Tree , List [Tree ], List [List [Tree ]]) = {
624+ /** The type arguemnts of a possibly curried call */
625+ def typeArgss (tree : Tree ): List [List [Tree ]] =
630626 @ tailrec
631- def loop (tree : Tree , targss : List [Tree ], argss : List [List [Tree ]]): (Tree , List [Tree ], List [List [Tree ]]) =
632- tree match {
633- case Apply (fn, args) =>
634- loop(fn, targss, args :: argss)
635- case TypeApply (fn, targs) =>
636- loop(fn, targs ::: targss, argss)
637- case _ =>
638- (tree, targss, argss)
639- }
640- loop(tree, Nil , Nil )
641- }
627+ def loop (tree : Tree , argss : List [List [Tree ]]): List [List [Tree ]] = tree match
628+ case TypeApply (fn, args) => loop(fn, args :: argss)
629+ case Apply (fn, args) => loop(fn, argss)
630+ case _ => argss
631+ loop(tree, Nil )
632+
633+ /** The term arguemnts of a possibly curried call */
634+ def termArgss (tree : Tree ): List [List [Tree ]] =
635+ @ tailrec
636+ def loop (tree : Tree , argss : List [List [Tree ]]): List [List [Tree ]] = tree match
637+ case Apply (fn, args) => loop(fn, args :: argss)
638+ case TypeApply (fn, args) => loop(fn, argss)
639+ case _ => argss
640+ loop(tree, Nil )
641+
642+ /** The type and term arguemnts of a possibly curried call, in the order they are given */
643+ def allArgss (tree : Tree ): List [List [Tree ]] =
644+ @ tailrec
645+ def loop (tree : Tree , argss : List [List [Tree ]]): List [List [Tree ]] = tree match
646+ case tree : GenericApply => loop(tree.fun, tree.args :: argss)
647+ case _ => argss
648+ loop(tree, Nil )
649+
650+ /** The function part of a possibly curried call. Unlike `methPart` this one does
651+ * not decompose blocks
652+ */
653+ def funPart (tree : Tree ): Tree = tree match
654+ case tree : GenericApply => funPart(tree.fun)
655+ case tree => tree
642656
643657 /** Decompose a template body into parameters and other statements */
644658 def decomposeTemplateBody (body : List [Tree ])(using Context ): (List [Tree ], List [Tree ]) =
0 commit comments