Json macros breakage, cant find matching apply/unapply
See original GitHub issueIm getting some macro breakage in what looks like a situation that should work.
This is with 2.2.0_M2 of play-json.
PlayJsonBoilerplate.scala:39: No apply function found matching unapply return types
[error] Json.reads[Collaborator]
[error] ^
But, this code works fine, and is in scope for the above ^
implicit lazy val ReadsCollaboratorCollaboratedUser: Reads[Collaborator.CollaboratedUser] = {
import com.heroku.platform.api.Collaborator.CollaboratedUser
Json.reads[Collaborator.CollaboratedUser]
}
Apply and Unapply line up afaik?
scala> import com.heroku.platform.api._
import com.heroku.platform.api._
scala> Collaborator.apply _
res0: (String, String, com.heroku.platform.api.Collaborator.CollaboratedUser) => com.heroku.platform.api.Collaborator = <function3>
scala> Collaborator.unapply _
res1: com.heroku.platform.api.Collaborator => Option[(String, String, com.heroku.platform.api.Collaborator.CollaboratedUser)] = <function1>
Must be to do with the nested case class in the companion?
object Collaborator {
case class CollaboratedUser(email: String, id: String)
}
case class Collaborator(created_at: String, id: String, user: CollaboratedUser)
Issue Analytics
- State:
- Created 10 years ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
Play JSON serialize/deserialize - scala - Stack Overflow
Play JSON serialize/deserialize ... Your code seems to compiles fine. Have you added other apply or unapply methods in Work object? – Cyrille ......
Read more >circe/circe - Gitter
Good morning! Are there any special specs2 matchers for circe.Json , which may take ignore order of object fields or presence/absence of null-valued...
Read more >Scala pattern matching: apply the unapply - Medium
apply (...) . We are using it to construct new instances of FullName without needing the new keyword. unapply does the opposite —...
Read more >[Solved]-Pattern match Jackson JSON in Scala-scala
case class DomainObjectA(v1: String, v2: String) object DomainObjectAExtractor { def unapply(m: Map[String, String]) = for { v1 <- m.get("key1") v2 ...
Read more >serialization in sbt - Google Groups
(I'm not actually sure play-json would break as long as we have apply and unapply, I think it reflects those and uses them...
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 Free
Top 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
I ran into a similar issue when having an enumeration defined in its companion class. I fixed this by being very explicit about the type within the case class definition.
Try seeing if this works:
case class Parent( id: String, child: Parent.Related.Child) { }
More recent duplicate #3244