-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore generated methods for default arguments #603
Ignore generated methods for default arguments #603
Conversation
This was discovered from this Stack Overflow question https://stackoverflow.com/q/73655638/29470 |
@@ -47,7 +47,7 @@ object ScalaAnnotationIntrospector extends NopAnnotationIntrospector with ValueI | |||
override def hasIgnoreMarker(m: AnnotatedMember): Boolean = { | |||
val name = m.getName | |||
//special cases to prevent shadow fields associated with lazy vals being serialized | |||
name == "0bitmap$1" || name.endsWith("$lzy1") || super.hasIgnoreMarker(m) | |||
name == "0bitmap$1" || name.endsWith("$lzy1") || name.contains("$default$") || super.hasIgnoreMarker(m) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is really the best way to filter these methods out, but it's the best way I could find.
Based on the spec at https://docs.scala-lang.org/sips/named-and-default-arguments.html#default-arguments-1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks - probably the best way to go
I wrote this test-first. Here are the failures that result without the change to
|
...st/scala/com/fasterxml/jackson/module/scala/introspect/ScalaAnnotationIntrospectorTest.scala
Show resolved
Hide resolved
Co-authored-by: Tim Moore <tim.moore@lightbend.com>
When a method with default arguments has a name that matches JavaBeans property conventions, the generated method that computes the default argument expression is detected as a property.