-
-
Notifications
You must be signed in to change notification settings - Fork 110
Open
Labels
Description
In the code below deriving JsonValueCodec[A]
ends in a compilation error.
When definition of ReqId
is changed to opaque type ReqId = Option[String]
, derivation succeeds.
object Wrappers {
opaque type ReqId <: Option[String] = Option[String]
object ReqId {
inline def apply(x: Option[String]): ReqId = x
given JsonValueCodec[ReqId] = JsonCodecMaker.make[Option[String]]
}
}
object JsoniterOpaque extends App {
import Wrappers.*
println(writeToString(ReqId(None))) // null
println(readFromString[ReqId]("null")) // None
case class A(r: ReqId)
/** Exception occurred while executing macro expansion.
* java.util.NoSuchElementException: head of empty list
*/
// given JsonValueCodec[A] = JsonCodecMaker.make
}