GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |
GeezerVison is showing github.com — [java] Fix #6393: UnusedPrivateMethod FP on overloaded methods when overload resolution fails by fudianchn · Pull Request #6947 · pmd/pmd Conversation
Contributor
WhatSuppress the WhyWhen overload resolution fails, PMD falls back to an arbitrary candidate symbol. The rule treated that fallback as the real selection and marked the other overloads as unused. Closes #6393. Root cause
HowTreat a failed selection like an unresolved call: if (calledMethod.isUnresolved() || selectionInfo.isFailed()) { handleUnresolvedCall(ref, selectionInfo, candidates); return; } This reuses the existing whitelist path — Testing
Notes
Fixes #6393
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…n overload resolution fails What: UnusedPrivateMethod reported a false positive on one of several overloaded private methods when a call's argument is the return value of a method declared in a type that is not on the auxiliary classpath (unresolved receiver/return type), causing overload resolution to fail. Root cause: When overload resolution fails (OverloadSelectionResult#isFailed()), the selected method symbol is an arbitrary fallback, not the actually-called overload. The rule only branched into the conservative "whitelist all same-named candidates" path when the symbol was unresolved (JExecutableSymbol#isUnresolved()). A failed-but-resolved fallback therefore caused only that one overload to be marked used, flagging the remaining overload(s) as unused. Fix: Treat a failed overload selection like an unresolved call, so all same-named private method candidates are whitelisted when the receiver may be an instance of the analysed class (existing handleUnresolvedCall logic). This is consistent with the rule's existing false-positive-avoiding trade-off for unresolved calls. Testing: New test case in UnusedPrivateMethod.xml reproducing the issue (expects 0 violations). Full UnusedPrivateMethodTest: 111 tests, 0 failures, 0 errors (2 pre-existing skipped). Signed-off-by: 付典 <[email protected]>
|
There was an error while loading. Please reload this page.
|
Compared to main: (comment created at 2026-08-14 11:51:01+00:00 for 05e0f8d) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…oad-6393 # Conflicts: # docs/pages/release_notes.md
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
[java] UnusedPrivateMethod: False positive with overloaded private methods called with values returned from methods defined in other classes
There was an error while loading. Please reload this page.