Skip to content

[java] Fix #6768: Resolve record component types before inference - #6871

Merged
UncleOwen merged 4 commits into
pmd:mainfrom
DragonFSKY:fix/6768-record-component-disambiguation
Jul 16, 2026
Merged

UncleOwen merged 4 commits into
pmd:mainfrom
DragonFSKY:fix/6768-record-component-disambiguation

Conversation

@DragonFSKY

Copy link
Copy Markdown
Contributor

Describe the PR

Record component types were excluded from early type-header disambiguation so
that record members remain in scope in the record header. However, their type
nodes were not disambiguated after the record body symbol table was installed.

When an anonymous-class argument causes type inference to inspect a sibling
implicit record accessor, the accessor return type therefore reads an unresolved
ASTClassType and throws an IllegalStateException.

This PR disambiguates only the record component type nodes after applying the
record body scope and before processing body declarations. It also adds a
regression test based on the original reproducer.

This prevents the processing error without changing record accessor or type
inference behavior.

Related issues

Validation

  • Reproduced the processing error with PMD 7.27.0-SNAPSHOT
    (283f0cba781c2057276cf4049bbe0c4878e9e8ea), exit code 5
  • Recompiled the modified SymbolTableResolver against the same snapshot and
    confirmed the reproducer completes with exit code 0
  • Checked generic, nested-type, varargs, primitive, annotated, and unresolved
    record component cases
  • ./mvnw -pl pmd-java -am -Dtest=SymbolTableResolverTest -Dsurefire.failIfNoSpecifiedTests=false test
    (2 tests, 0 failures, 0 errors)
  • ./mvnw -pl pmd-java -am test
    (9,751 PMD Java tests, 0 failures, 0 errors, 20 skipped)
  • ./mvnw clean verify (all 44 reactor modules succeeded)
  • git diff --check

Ready?

  • Added unit tests for fixed bug
  • Passing all unit tests
  • Complete build ./mvnw clean verify passes
  • Added in-code documentation where needed

@pmd-actions-helper

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

Copy link
Copy Markdown
Contributor

Documentation Preview

Compared to main:
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.
There are 0 changed duplications, 0 new duplications and 0 removed duplications.
There are 0 changed CPD errors, 0 new CPD errors and 0 removed CPD errors.

Regression Tester Report

(comment created at 2026-07-16 13:18:14+00:00 for 6ef1b53)

@DragonFSKY
DragonFSKY marked this pull request as ready for review July 14, 2026 14:13

@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!

(I've moved the new test to the bottom, both because it's new and more specific than the existing one)

@UncleOwen UncleOwen added this to the 7.27.0 milestone Jul 16, 2026
@UncleOwen
UncleOwen merged commit aed5491 into pmd:main Jul 16, 2026
13 checks passed
@DragonFSKY

Copy link
Copy Markdown
Contributor Author

Thanks for the review and for moving the new test into the more specific section!

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] Disambiguation IllegalStateException resolving a synthesized record accessor used as a call argument alongside an anonymous class

2 participants