Skip to content

Add support for 22+ case class in format macros - #1368

Open
Iilun wants to merge 1 commit into
playframework:mainfrom
Iilun:support-any-arity
Open

Add support for 22+ case class in format macros#1368
Iilun wants to merge 1 commit into
playframework:mainfrom
Iilun:support-any-arity

Conversation

@Iilun

@Iilun Iilun commented Jul 28, 2026

Copy link
Copy Markdown

Pull Request Checklist

  • Have you read through the contributor guidelines?
  • Have you squashed your commits?
  • Have you added copyright headers to new files?
  • Have you updated the documentation?
  • Have you added tests for any changed functionality?

Fixes

Fixes #3

Purpose

This PR introduces support for macros for case classes with more than 22 fields.

Background Context

The existing macro could not handle case classes with more than 22 fields and failed with an error No unapply or unapplySeq function found for ....

Implementation choices

My goal in this implementation was to keep all existing code paths exactly the same, and for the new approach, take inspiration from the play-json-extensions macro.

This was to ensure that if someone used custom apply / unapply, it would not be impacted, and my new implementation only starts when the aforementioned error would otherwise have surfaced, only introducing a new behavior, and not affecting existing code.

This does mean that I had to duplicate the test coverage, since the code paths for case class <22 and 22+ are different. This produces a quite heavy diff, I am unsure what strategy to adopt here.

I also avoided messing too much with the utility CaseClass class, as its code is not easily readable, and only edited it to reuse existing code.

If this choice does not meet the repo criteria, I will happily refactor this, to have a uniform code path if required (however I am afraid of regressions with such an approach, since the previous macro approach had a lot of quirks)

Docs

I searched the documentation, but it mentioned that case class were supported, so I wasn't sure what to add to it, left it as is for now.

Thank you for your feedback !

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.

Implement support for > 22 field case classes in macros

1 participant