Access to the lambda argument names passed with an identifier, not the lambda himself


I’m implemented a macro to be able to extract the lambda argument names.

object MacroTest {

  def getLambdaArgNames[A, B](f: A => B): String = macro getLambdaArgNamesImpl[A, B]

  def getLambdaArgNamesImpl[A, B](c: Context)(f: c.Expr[A => B]): c.Expr[String] = {
    import c.universe._
    val Function(args, body) = f.tree
    val names =
    val argNames = names.mkString(", ")
    val constant = Literal(Constant(argNames))

This macro is working when I call it wit the lambda directly but not with the lambda identifier.

 val f = (e1: Expr[Int]) => e1 === 3
 val argNames = MacroTest.getLambdaArgNames((e1: Expr[Int]) => e1 === 3) // working
 val argNames = MacroTest.getLambdaArgNames(f) // not working

It’s like everything in the right side of f is not available while I have a context, I’m just wondering if there is any to make it work with the lambda identifier ?