I need to have some implicit values provided by the compiler in a macro. The basic setup is this:
import scala.quoted.*
object From:
inline def testFromExpr0[K,V](inline l: Tuple2[K,V]): Any =
${ testFromExprImpl0('l) }
def testFromExprImpl0[K, V](x: Expr[Tuple2[K,V]])(using Type[K], FromExpr[K], Type[V], FromExpr[V], Quotes): Expr[Int] =
val v = x.valueOrAbort
'{1}
end From
The code above can be found here. In the case above I get the following error:
[error] -- Error: /home/hmf/VSCodeProjects/sploty/meta/src/icollection/FromExpr0.scala:90:28
[error] 90 | ${ testFromExprImpl0('l) }
[error] | ^
[error] |No given instance of type quoted.FromExpr[K] was found for parameter x$3 of method testFromExprImpl0 in object From.
[error] |I found:
[error] |
[error] | quoted.FromExpr.ByteFromExpr[T]
[error] |
[error] |But given instance ByteFromExpr in object FromExpr does not match type quoted.FromExpr[K].
[error] one error found
I have made many attempts to solve this. In this example I get the error:
Malformed macro parameter: x$2
Parameters may only be:
* Quoted parameters or fields
* Literal values of primitive types
* References to `inline val`s
I found this issue, which seems to indicate that the error message above is correct.
So how can I use the required implicits? I need these to use the correct FromExpr
classes from within a macro (see this question).
TIA