Skip to content

Fix the OWritesBench compilation on Scala 2 - #1485

Merged
mergify[bot] merged 1 commit into
playframework:mainfrom
linyiru:fix/owrites-bench-compile
Oct 7, 2026
Merged

mergify[bot] merged 1 commit into
playframework:mainfrom
linyiru:fix/owrites-bench-compile

Conversation

@linyiru

@linyiru linyiru commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • Have you read through the contributor guidelines?
  • Have you squashed your commits?
  • Have you added copyright headers to new files? (no new files)
  • Have you updated the documentation? (benchmarks only, nothing to document)
  • Have you added tests for any changed functionality? (benchmarks only)

Purpose

On main, the benchmarks project does not compile on Scala 2.12 or 2.13:

[error] OWritesBench.scala:60:12: diverging implicit expansion for type play.api.libs.json.Writes[T1]
[error] starting with method Tuple22W in trait GeneratedWrites
[error]     Writes.genericMapWrites.writes(employeeIdMap)

and the same at line 64 for Writes.keyMapWrites.writes(scoreMap). Scala 3.3 compiles it. Because the default scalaVersion is 2.13, benchmarks / Jmh / run fails for every benchmark, not just this one.

This passes the type arguments explicitly: genericMapWrites[String, Map] and keyMapWrites[Int, Double, Map].

The file is also reformatted with scalafmt. It had not been formatted since it was added, because validateCode does not check the benchmarks project (which is also why CI did not catch the compile error).

Checked locally (JDK 17): +benchmarks/Jmh/compile passes on 2.12.21, 2.13.18 and 3.3.8, and benchmarks/scalafmtCheckAll passes. On main, benchmarks/compile fails on 2.12.21 and 2.13.18 and passes on 3.3.8.

References

Found while benchmarking append for the review of #1482 (#1482 (comment)). OWritesBench was added in #1430.

AI disclosure: I directed and verified this work; Claude Code (Claude Opus) assisted with the investigation, the patch and this description.

🤖 Generated with Claude Code

Writes.genericMapWrites and Writes.keyMapWrites were called without type
arguments, which fails with a diverging implicit expansion on Scala 2.12
and 2.13, so the benchmarks project did not compile there (Scala 3 was
fine). Pass the type arguments explicitly.

Also format the file with scalafmt; it had not been formatted since it
was added, as validateCode does not check the benchmarks project.
@mergify

mergify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@mergify

mergify Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 9 minutes 21 seconds in the queue, including 8 minutes 53 seconds running CI.

Required conditions to merge

@mergify mergify Bot added the queued label Oct 7, 2026
@mergify mergify Bot mentioned this pull request Oct 7, 2026
7 of 11 tasks
@mergify
mergify Bot merged commit 2455a5a into playframework:main Oct 7, 2026
27 checks passed
@mergify mergify Bot removed the queued label Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants