You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New check request: flag method annotations on record components when they have no effect #5183
The annotation on baz has an effect: it will show up in the list returned by Foo.class.getMethod("baz").getAnnotations(), because METHOD-target annotations get copied from a record component to an implicit accessor method. However, they are not copied to an explicit accessor method such as bar(). So the annotation on bar has no effect. It does not appear anywhere in the resultant class-file. Presumably if someone writes something like the above, they mean it to have an effect, so it would make sense for Error Prone to warn them that it doesn't.
then the annotation has no effect and merits a warning.
(This was inspired by #5174, which is specifically about @Override. It turns out that @Override on a record component has no effect whatsoever, and that's a knottier question.)
Activity
eamonnmcmanus commentedon Jul 28, 2025
I'm realizing that this is basically a dup of #5177.