I have the following trait / macro definition:
trait Test[A[_]] {
def hello: String
}
object Test {
def getTest[A[_]]: Test[A] = macro Impl.getTest[A]
}
class Impl(c: whitebox.Context) {
import c.universe._
def getTest[A[_]](implicit tt: WeakTypeTag[A[_]]): c.Expr[Test[A]] = {
reify {
new Test[A] {
override def hello: String = "test"
}
}
}
}
Which i try to use like so
val test = Test.getTest[List]
println(test.hello)
However, when I try to build, i get the error "Macro expansion contains free type variable A defined by getTest in Test.scala.... Have you forgotten to use c.WeakTypeTag annotation for this type parameter? ". What is the correct way for me to provide a typetag for a higher-kinded type?