Json 隐式泛型函数的签名是什么,它使用Scala宏生成
我需要在JSON密封的trait层次结构中序列化,它看起来像:Json 隐式泛型函数的签名是什么,它使用Scala宏生成,json,scala,implicit,scala-macros,Json,Scala,Implicit,Scala Macros,我需要在JSON密封的trait层次结构中序列化,它看起来像: sealed trait Foo[T] case class Bar(x: Int) extends Foo[Int] case class Baz(s: String) extends Foo[String] case object Bah extends Foo[Void] 我正在为这个serialiati Fork使用play json变体。我做了必要的更改,或者我认为是这样:) 宏签名如下: object
sealed trait Foo[T]
case class Bar(x: Int) extends Foo[Int]
case class Baz(s: String) extends Foo[String]
case object Bah extends Foo[Void]
我正在为这个serialiati Fork使用play json变体。我做了必要的更改,或者我认为是这样:)
宏签名如下:
object Variants {
/**
* @tparam A The base type of a case class hierarchy.
* @return A [[play.api.libs.json.Format]] for the type hierarchy of `A`.
*/
def format[A]: Format[A] = macro Impl.format[A]
问题是我不知道隐式函数
的签名应该是什么
我试过了
implicit def fooFormat[A]() = Variants.format[Foo[A]]
implicit def fooFormat[A <: Foo[A]]() = Variants.format[A]
implicit def fooFormat[A]()=Variants.format[Foo[A]]
隐式def fooFormat[AA你能分享代码吗?它在github中。