Better way to get product elements #264
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.
TL;DR
Prefer using Scala 2.13's way to get product element names
Type
Are all requirements met?
Complete description
Since most users should have been on Scala 2.13, we can have a better way to get product element names, with fallback to Java's way.
getDeclaredFields
from Java is less reliable, and it doesn't get super classes' declared fields. We could do that ourselves, but it is impossible to get the correct order.For case class like:
productElementNames
can correctly get[a, c, b]
for instance ofA
, butgetDeclaredFields
can only getc
for instance ofA
. It won't work if we try to recursively go up to get all declared fields, because we would not be able to put up a correct order wherec
appears betweena
andb
.Tracking Issue
NA
Follow-up issue
NA