Closed
Description
Compiler version
3.2.0
Minimized code
//file a.scala
object betaReduceTest {
inline def macroPolyFun[A](inline arg: A, inline f: [Z] => Z => String): String =
${ macroPolyFunImpl[A]('arg, 'f) }
def macroPolyFunImpl[A: Type](arg: Expr[A], f: Expr[[Z] => Z => String])(using Quotes): Expr[String] =
Expr.betaReduce('{ $f($arg) })
inline def macroFun[A](inline arg: A, inline f: A => String): String =
${ macroFunImpl[A]('arg, 'f) }
def macroFunImpl[A: Type](arg: Expr[A], f: Expr[A => String])(using Quotes): Expr[String] =
Expr.betaReduce('{ $f($arg) })
}
//file b.scala
object betaReduceTest2 {
def test: Unit = {
betaReduceTest.macroPolyFun("foo", [Z] => (arg: Z) => arg.toString)
betaReduceTest.macroFun("foo", arg => arg.toString)
}
}
Decompiled code (with Fernflower)
public void test() {
String var10000 = (String)((Function1)(new 1())).apply("foo");
"foo".toString();
}
Expectation
That both the normal and poly function both beta reduce