Skip to content

Conversation

@honnix
Copy link
Member

@honnix honnix commented Oct 23, 2023

TL;DR

Prefer using Scala 2.13's way to get product element names

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added (covered by IT)
  • Code documentation added
  • Any pending items have an associated Issue

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:

class B(val a: String, val b: String)

case class A(override val a: String, c: String, override val b: String) extends B(a, b)

productElementNames can correctly get [a, c, b] for instance of A, but getDeclaredFields can only get c for instance of A. 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 where c appears between a and b.

Tracking Issue

NA

Follow-up issue

NA

Signed-off-by: Hongxin Liang <honnix@users.noreply.github.com>
Signed-off-by: Hongxin Liang <honnix@users.noreply.github.com>
@andresgomezfrr andresgomezfrr merged commit 54d2410 into master Oct 24, 2023
@andresgomezfrr andresgomezfrr deleted the get-all-declared-fields branch October 24, 2023 07:23
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.

3 participants