How to match function Expr in scala 3 macros

Viewed 144

With scala 3 quotes syntax:

'{...}

How to match a function expression?

def macroImpl(expr: Expr[T => Any])(using q: Quotes): Expr[Any] = {
 expr match {
   case '{/*how to match function here*/} => ???
 }
}
1 Answers

A way is:

def macroImpl[T : Type](expr: Expr[T => Any])(using q: Quotes): Expr[Any] = {  
    expr match {
      case '{(x : T) => ${body} : Any } => .... //do something
    }
}
Related