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*/} => ???
}
}
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*/} => ???
}
}
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
}
}