-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MethodSpec.overriding shouldn't copy annotations #482
Comments
Two valid points, Gregory. What do you guys prefer:
|
My vote is for the first one. It's the simple, safe, predictable behavior. The second one, is unlikely to be all that useful. You have to know something about the annotations on the method you're overriding in order to be able to predict if copying them is safe/correct. If you've come that far you might as well just put them on the overriding method yourself. There might be a version that took a The third assumes that a blacklist (rather than a whitelist) is what you're going to want. I think more often than not, it might be the other way around, but I think a |
…ons for the reasons cited in issue square#482.
* Don't copy parameter annotations when creating a ParameterSpec. This further preserves the behaviour discussed in #482. Unifying it for both MethodSpec.overriding and ParameterSpec.get. * Add compilation test for when overriding a method with private annotations. * Address PR comments: * Remove unused import * Rename newly added test
Is it only me who finds it really annoying that copying a parameter WITH annotations now is a major effort that involves research into how to do that? Aside from that, I find the behaviour of ParamSpec.get() very unexpected. I would have expected it to give me an object that contains the same information as its parameter, not some stripped down version. It's more ParamSpec.getSomethingThatLooksABitLike() now... PS: I'm a bit annoyed because I had to find out why my code wasn't working from reading comments in yours. Not even in a javadoc, but hidden away inside the method. |
For a few reasons:
@Nullable
, for example, might apply to the method being overridden, but not necessarily to the implementation of the override.The text was updated successfully, but these errors were encountered: