Hi!
I’m trying to generically convert a constructor like Function2[A, B, C] into Function1[(A, B), C].
In my macro I use Select:
val ctor: Term = ???
val tupled = Select.unique(ctor, "tupled")
But later, when I use tupled.asExprOf[Tuple => Any] I’m getting the following compile-time error:
|Exception occurred while executing macro expansion.
|java.lang.Exception: Expr cast exception: ((a: scala.Boolean, f: rs$line$1.Foo) => new rs$line$1.Bar(a, f)).tupled
|of type: scala.Function2[scala.Boolean, rs$line$1.Foo, rs$line$1.Bar].tupled
|did not conform to type: scala.Function1[scala.Tuple, scala.Any]
So, for some reasons .tupled part was not invoked.
I figure out that on TypeRef-level I can get rid of it with widen method, but how do I get rid of it on Term-level?