pbdirect icon indicating copy to clipboard operation
pbdirect copied to clipboard

Nested object - java.util.NoSuchElementException: head of empty list

Open JakubDziworski opened this issue 7 years ago • 1 comments

exception is thrown when:

    case class A(b: B)
    case class B(c: Option[C])
    case class C(s1: String, s2: String) 

    val msg = A(B(Some(C("ds", "xd"))))
    val bytes = msg.toPB
    val parsed = bytes.pbTo[A]

If you change B to to case class B(c: C) it works. If you change C to case class B(c: C) it works.

Am I doing something wrong or is it bug?

JakubDziworski avatar Aug 02 '18 04:08 JakubDziworski

I believe you missed the following import cats.instances..option._ when you call msg.toPB ? If you import cats.instances.option._ and then run your code it should be ok.

btlines avatar Sep 20 '18 23:09 btlines