question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compile error when encode a case class

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
travisbrowncommented, Aug 14, 2015

Thanks for the report! I’m at a conference today but I’ll take a look this evening.

0reactions
travisbrowncommented, Aug 27, 2015

The error message situation is a little better after #43, but it doesn’t fix this and the message still isn’t great:

// Exiting paste mode, now interpreting.

<console>:38: error: could not find implicit value for parameter e: io.circe.Encoder[Bbbbb]
       kk.asJson
          ^
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found