Compile error when encode a case class
See original GitHub issueI don’t find the reason with the bug, just provide all I know.
[enuma] $ console
[info] Starting scala interpreter...
[info]
import scalaz._
import Scalaz._
import io.circe._
import io.circe.generic.auto._
import io.circe.jawn._
import io.circe.syntax._
Welcome to Scala version 2.11.7 (OpenJDK 64-Bit Server VM, Java 1.8.0_51).
Type in expressions to have them evaluated.
Type :help for more information.
scala> :paste
// Entering paste mode (ctrl-D to finish)
case class Aaaaa(
id: Option[Long],
trade111: Option[Long],
trade222: Option[Long],
trade333: Option[Long],
trade444: Option[Long],
enterprise: Option[Long]
)
case class Ccccc(name: String)
case class Bbbbb(energy: Aaaaa, street1: Ccccc, street2: Ccccc, street3: Ccccc)
//implicit val aabbcc = Encoder[Aaaaa]
val kk: Bbbbb = ???
kk.asJson
// Exiting paste mode, now interpreting.
//Tips: Here complete failed
<console>:43: error: diverging implicit expansion for type io.circe.Encoder[Bbbbb]
starting with method encodeCaseClass in trait GenericInstances
kk.asJson
^
scala> :paste
// Entering paste mode (ctrl-D to finish)
case class Aaaaa(
id: Option[Long],
trade111: Option[Long],
trade222: Option[Long],
trade333: Option[Long],
trade444: Option[Long],
enterprise: Option[Long]
)
case class Ccccc(name: String)
case class Bbbbb(energy: Aaaaa, street1: Ccccc, street2: Ccccc, street3: Ccccc)
implicit val aabbcc = Encoder[Aaaaa]
val kk: Bbbbb = ???
kk.asJson
// Exiting paste mode, now interpreting.
//Tips: Here complete successfully
scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
... 47 elided
scala> :paste
// Entering paste mode (ctrl-D to finish)
case class Aaaaa(
id: Option[Long],
trade111: Option[Long],
enterprise: Option[Long]
)
case class Ccccc(name: String)
case class Bbbbb(energy: Aaaaa, street1: Ccccc, street2: Ccccc, street3: Ccccc)
//implicit val aabbcc = Encoder[Aaaaa]
val kk: Bbbbb = ???
kk.asJson
// Exiting paste mode, now interpreting.
//Tips: Here complete successfully
scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
... 47 elided
scala> :paste
// Entering paste mode (ctrl-D to finish)
case class Aaaaa(
id: Option[Long],
trade111: Option[Long],
enterprise: Option[Long]
)
case class Ccccc(name: String)
case class Bbbbb(energy: Aaaaa, street1: Ccccc)
//implicit val aabbcc = Encoder[Aaaaa]
val kk: Bbbbb = ???
kk.asJson
// Exiting paste mode, now interpreting.
//Tips: Here complete failed
<console>:40: error: diverging implicit expansion for type io.circe.Encoder[Bbbbb]
starting with method encodeCaseClass in trait GenericInstances
kk.asJson
^
scala> :paste
// Entering paste mode (ctrl-D to finish)
case class Aaaaa(
id: Option[Long],
trade111: Option[Long],
enterprise: Option[Long]
)
case class Ccccc(name: String)
case class Bbbbb(energy: Aaaaa, street1: Ccccc)
implicit val aabbcc = Encoder[Aaaaa]
val kk: Bbbbb = ???
kk.asJson
// Exiting paste mode, now interpreting.
//Tips: Here complete successfully
scala.NotImplementedError: an implementation is missing
at scala.Predef$.$qmark$qmark$qmark(Predef.scala:225)
... 47 elided
scala>
It seems that sometimes I have to provide implicit val aabbcc = Encoder[Aaaaa], and it looks like that complete always successfully when I provide the implicit val aabbcc = Encoder[Aaaaa], and sometimes fail when I just type kk.asJson without implicit. Any fix or suggest?
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Why is "Unable to find encoder for type stored in a Dataset ...
Unable to find encoder for type stored in a Dataset. Primitive types (Int, String, etc) and Product types (case classes) are supported by...
Read more >circe/circe - Gitter
I have a family of case classes where I use circe's auto encoding/decoding and the withDiscriminator configuration. It works really well with minimal...
Read more >Compile error when using a companion object of a case class ...
From your compile error, it looks like jsonFormat2 expects a two-argument function. Do you mean to pass the constructors of Foo and Bar...
Read more >passing anonymous case classes as arguments to ...
So this would also throw a compile error of "not found: type model". case class User(name:String="Joe"). def parseRequest[T](model:T): Unit = {.
Read more >Language Guide (proto3) | Protocol Buffers
In proto3, repeated fields of scalar numeric types use packed encoding by default. ... For Java, the compiler generates a .java file with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the report! I’m at a conference today but I’ll take a look this evening.
The error message situation is a little better after #43, but it doesn’t fix this and the message still isn’t great: