Skip to content
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

Add warning for property assignment using private setter in non-final class #1333

Open
eric-milles opened this issue Jan 10, 2022 · 0 comments
Assignees
Milestone

Comments

@eric-milles
Copy link
Member

eric-milles commented Jan 10, 2022

Consider the following:

class C {
  def m() { x = null }
  private void setX(x) {}
}
class D extends C /*implements Map*/ {
  /*
  @Delegate Map m
  void setX(x) { }
  void set(String name, value) { }
  */
}
new D().m()

The expression "x = null" will not make use of the private setter of C if one of the items in D is uncommented. "setX(null)" is safe or changing the visibility of setX to at least package-private or enabling static compilation for the call site prevents the interception as well. A warning could help bring awareness to this possibility.

@eric-milles eric-milles added this to the v4.5.0 milestone Jan 10, 2022
@eric-milles eric-milles self-assigned this Jan 10, 2022
@eric-milles eric-milles removed this from the v4.5.0 milestone Mar 31, 2022
@eric-milles eric-milles added this to the v5.6.0 milestone Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant