Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error on nested case classes with the same type #1

Closed
dbronecki opened this issue May 18, 2017 · 3 comments
Closed

Compilation error on nested case classes with the same type #1

dbronecki opened this issue May 18, 2017 · 3 comments
Labels

Comments

@dbronecki
Copy link
Contributor

dbronecki commented May 18, 2017

The following code:

import pl.iterators.kebs.json.KebsSpray
import spray.json.{DefaultJsonProtocol, JsonFormat}

class KebsTest {
  import ThingProtocol._

  case class Thing(thingId: String, parent: Option[Thing])

  val t = Thing("child", Some(Thing("parent", None)))

  implicitly[JsonFormat[Thing]].write(t)
}

object ThingProtocol extends DefaultJsonProtocol with KebsSpray

Gives error:

[error] (...)/KebsTest.scala:13: diverging implicit expansion for type routers.ThingProtocol.JF[Option[KebsTest.this.Thing]]
[error] starting with macro method jsonFlatFormat in trait KebsSpray
[error]   implicitly[JsonFormat[Thing]].write(t)
[error]             ^
[error] one error found
@marcin-rzeznicki
Copy link
Contributor

I fixed this issue in 938a9c9 . The fix involves new macro - jsonFormatRec[T] which materializes correct recursive lazy RootJsonFormat[T]. Could you please test it? Please check out tests if you want to see how to use it. Thanks!

@dbronecki
Copy link
Contributor Author

It's working fine. Thanks!

@marcin-rzeznicki
Copy link
Contributor

Thank you!

pk044 pushed a commit that referenced this issue Mar 14, 2024
Structure types value enums
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants