feat: removing private from typemapper #1674
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
Resolves #1664
Makes TypeMappers no longer private case class fields, so we can use
magnolia
(or, potentially, other typeclass derivation libs) that rely on-Yretain-trees
to derive default values.Why
See #1664
I understand that this could be controversial, as it makes this a public API - but I would argue that all generated case class fields (including defaults) should be accessible by their owner.
Now, protobuf's generated code sits in an awkward spot between "owned by the person who generates and uses the scala code" and "owned by the person owning the proto files" (which, depending on your org shape, are likely to be 2 and more teams).
But, since it is
scalapb
that allows users to customize fields, effectively breaking the contract laid out by the.proto
files, that makes the scala code owners the definitive owners of the generated files and, as such, the one who should have access to all fields.Lastly, since proto fields are, by default, nullable/optional, having access to their default case class values is important.
Test
See https://github.com/chollinger93/scalapb-issue1664/tree/fix for a test repo + instructions
Before
After