Skip to content

[java] Fix #6867: Handle module imports in UnnecessaryFullyQualifiedName - #6868

Merged
UncleOwen merged 3 commits into
pmd:mainfrom
DragonFSKY:fix/6867-module-import-scope
Jul 29, 2026
Merged

UncleOwen merged 3 commits into
pmd:mainfrom
DragonFSKY:fix/6867-module-import-scope

Conversation

@DragonFSKY

Copy link
Copy Markdown
Contributor

Describe the PR

UnnecessaryFullyQualifiedName could crash when reporting a type made available
through a module import because the rule did not handle the MODULE_IMPORT
scope. The module-import resolver also returned only the first matching type,
which discarded ambiguity when multiple imported modules exported types with
the same simple name.

This PR changes the module-import resolver to collect all matching exported
types, so ambiguous names are preserved and do not produce false positives. It
also adds reporting reasons for module imports and compact compilation units.

Regression coverage includes unambiguous module imports, ambiguous types across
modules and within one module, and implicit imports in compact compilation
units. A release-note entry is included as well.

Related issues

Ready?

  • Added unit tests for fixed bug/feature
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes (checked automatically by github actions)

@DragonFSKY
DragonFSKY marked this pull request as ready for review July 13, 2026 18:29
@pmd-actions-helper

pmd-actions-helper Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Documentation Preview

⚠️ Running pmdtester failed, this message is mainly used to remind the maintainers of PMD.

(comment created at 2026-07-29 19:11:51+00:00 for b2aa545)

@DragonFSKY
DragonFSKY force-pushed the fix/6867-module-import-scope branch from eb22ebc to 6d968d7 Compare July 17, 2026 09:41
We always run the regression tests with the latest java version unless
something different is specified.

@UncleOwen UncleOwen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@UncleOwen
UncleOwen merged commit d791b02 into pmd:main Jul 29, 2026
10 of 12 checks passed
@UncleOwen UncleOwen added this to the 7.27.0 milestone Jul 29, 2026
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.

[java] UnnecessaryFullyQualifiedName: ContextedAssertionError: This should be unreachable: unknown constant ScopeInfo: MODULE_IMPORT

2 participants