sealed trait Foo[T]
case class A() extends Foo[String]
case class B[V](v: V) extends Foo[Int]
given ToExpr[A] with {
def apply(x: A)(using Quotes) =
'{ A() }
}
given ToExpr[B] with {
def apply(x: B[_])(using Quotes) =
'{ B(x.v) }
}
inline def of[T]: RType[T] = ${ ofImpl[T]() }
def ofImpl[T]()(using quotes:Quotes)): Expr[Foo[T]] =
import quotes.reflect.*
Expr( B(15).asInstanceOf[RType[T]] ) // <<<---Doesn't work ;-)
I need my macro to return the generalized Foo[T], not the specific implementation.
Any way to do this?