Skip to content

Commit

Permalink
Merge pull request #1022 from playframework/mergify/bp/2.10.x/pr-993
Browse files Browse the repository at this point in the history
[2.10.x] Fix #974 – Scala 3 macro cannot find Writes for Seq[Map[String, T]] (backport #993) by @sgodbillon
  • Loading branch information
mkurz authored Apr 29, 2024
2 parents 3fca971 + eed1458 commit 01b3cce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ trait DefaultWrites extends LowPriorityWrites with EnumerationWrites {
* Serializer for Map[String,V] types.
*/
@deprecated("Use `genericMapWrites`", "2.8.0")
implicit def mapWrites[V: Writes]: OWrites[MapWrites.Map[String, V]] = MapWrites.mapWrites
def mapWrites[V: Writes]: OWrites[MapWrites.Map[String, V]] = MapWrites.mapWrites

implicit def keyMapWrites[K: KeyWrites, V: Writes, M[K, V] <: MapWrites.Map[K, V]]: OWrites[M[K, V]] = {
val kw = implicitly[KeyWrites[K]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ final class WritesSharedSpec extends AnyWordSpec with Matchers {
"write lazy maps" in {
Json.toJson(Map("a" -> 1).map(kv => kv._1 -> (kv._2 + 1))).mustEqual(Json.obj("a" -> 2))
}

"write a map nested in a seq" in {
Json.toJson(Seq(Map("a" -> 1))).mustEqual(Json.arr(Json.obj("a" -> 1)))
}
}

"Iterable writes" should {
Expand Down

0 comments on commit 01b3cce

Please sign in to comment.