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

Kebs spray-json can't resolve implicit for particular case class #11

Closed
dbronecki opened this issue Jun 1, 2017 · 2 comments
Closed

Comments

@dbronecki
Copy link
Contributor

Following code:

  test("issue") {
    import KebsProtocol._
    val jf = implicitly[JsonFormat[Request]]
  }
  case class Request(region: String, currency: String, date: String, code: String, items: List[RequestItem])
  case class RequestItem(itemCode: String, language: String, answers: Option[List[Answer]], requirements: String, travellers: String)
  case class Answer(answer: String)

Gives compilation error:

[error] diverging implicit expansion for type spray.json.JsonFormat[SprayValueEnumJsonFormatTests.this.Request]
[error] starting with macro method jsonValueEnumFormat in trait KebsEnumFormats
[error]     val jf = implicitly[JsonFormat[Request]]
@marcin-rzeznicki
Copy link
Contributor

I'm not sure if there's much I can do about it. Probably the depth of implicit search is too big for the compiler. Eg. if you change Option[List[Answer]] to List[Answer] everything is fine. Another workaround is to define implicit val requestFormat = jsonFormatN[Request] manually. It is also true that changing Answer by adding dummy field makes it compile - probably because only RootJsonFormat macro is being expanded in this case.

I do not have any idea how I could solve it. I'll leave this issue open for a while - in case someone might have better idea.

Thanks for reporting

@marcin-rzeznicki
Copy link
Contributor

Looks like fb29526 magically fixed this issue. Closing 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants