-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[java] MissingOverride - fix false positive with mixing type vars #3675
[java] MissingOverride - fix false positive with mixing type vars #3675
Conversation
Generated by 🚫 Danger |
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 think this fix is wrong. The thing is, defaultValue(C)
and defaultValue(Collection<? extends V>)
are override equivalent, so the culprit is not the method areOverrideEquivalent
. Rather, MissingOverride should not be checking override equivalence, but instead whether the subclass method is a subsignature of the superclass method, using the method TypeOps.isSubSignature
instead of TypeOps.areOverrideEquivalent
, as per the spec about overriding
Rule: MissingOverride
I found this while trying to run PMD 7 on PMD 7 sources (dogfood).
It addresses the following false positive:
[INFO] PMD Failure: net.sourceforge.pmd.properties.PropertyBuilder$GenericCollectionPropertyBuilder:402 Rule:MissingOverride Priority:1 The method 'defaultValue(Collection<? extends V>)' is missing an @Override annotation..
pmd/pmd-core/src/main/java/net/sourceforge/pmd/properties/PropertyBuilder.java
Line 402 in f36b99f
The java compiler doesn't allow here an
@Override
. We would need to useC val
instead ofCollection<? extends V> val
.While this erased type for both is
Collection
, the java compiler doesn't see it that way...