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

[java] MissingOverride - fix false positive with mixing type vars #3675

Merged

Conversation

adangel
Copy link
Member

@adangel adangel commented Dec 3, 2021

Rule: MissingOverride

I found this while trying to run PMD 7 on PMD 7 sources (dogfood).

It addresses the following false positive:

The java compiler doesn't allow here an @Override. We would need to use C val instead of Collection<? extends V> val.
While this erased type for both is Collection, the java compiler doesn't see it that way...

@adangel adangel added this to the 7.0.0 milestone Dec 3, 2021
@adangel adangel mentioned this pull request Dec 3, 2021
4 tasks
@pmd-test
Copy link

pmd-test commented Dec 3, 2021

2 Messages
📖 Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 2 violations, 0 errors and 0 configuration errors.
Full report
📖 Compared to master:
This changeset changes 48809 violations,
introduces 25855 new violations, 5 new errors and 0 new configuration errors,
removes 179102 violations, 27 errors and 3 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 2 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 48809 violations,
introduces 25855 new violations, 5 new errors and 0 new configuration errors,
removes 179102 violations, 27 errors and 3 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 2 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 48809 violations,
introduces 25855 new violations, 5 new errors and 0 new configuration errors,
removes 179102 violations, 27 errors and 3 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 4 new violations, 0 new errors and 0 new configuration errors,
removes 286 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 45901 violations,
introduces 25415 new violations, 38 new errors and 0 new configuration errors,
removes 182110 violations, 27 errors and 3 configuration errors.
Full report
Compared to pmd/7.0.x:
This changeset changes 0 violations,
introduces 0 new violations, 0 new errors and 0 new configuration errors,
removes 0 violations, 0 errors and 0 configuration errors.
Full report
Compared to master:
This changeset changes 45977 violations,
introduces 25662 new violations, 38 new errors and 0 new configuration errors,
removes 182076 violations, 27 errors and 3 configuration errors.
Full report

Generated by 🚫 Danger

Copy link
Member

@oowekyala oowekyala left a 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

@oowekyala oowekyala merged commit 13bf901 into pmd:pmd/7.0.x Jan 2, 2022
@adangel adangel deleted the pmd7-missingoverride-false-positive branch January 8, 2022 18:49
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants