Skip to content

[kotlin] Fix #6891: Use KtModifiers container in AnnotationFqnAnnotator - #6892

Merged
adangel merged 3 commits into
pmd:mainfrom
stokpop:fix/kotlin-annotation-fqn-annotator-6891
Jul 21, 2026
Merged

adangel merged 3 commits into
pmd:mainfrom
stokpop:fix/kotlin-annotation-fqn-annotator-6891

Conversation

@stokpop

@stokpop stokpop commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #6891

AnnotationFqnAnnotator.collectAnnotationNodes() used .children(KtModifier.class)
but KtModifier (singular) is an individual modifier keyword — annotations live under
KtModifiers (plural, the container rule). The chain returned empty for all declaration
types, so @TypeName was never set on UnescapedAnnotation/SingleAnnotation nodes.

Fix: use .children(KtModifiers.class) as the first step.

Added regression test unescapedAnnotationOnFunctionHasTypeName in KotlinTypeAnnotationVisitorTest.

…nAnnotator

collectAnnotationNodes() used .children(KtModifier.class) but KtModifier (singular)
is an individual modifier keyword; annotations live under KtModifiers (plural container).
The chain returned empty for all declaration types, so @typename was never set on
UnescapedAnnotation/SingleAnnotation nodes.

Fix: use .children(KtModifiers.class) as the first step.
Add regression test unescapedAnnotationOnFunctionHasTypeName.
@stokpop
stokpop force-pushed the fix/kotlin-annotation-fqn-annotator-6891 branch from 9f23a7a to 61bb626 Compare July 20, 2026 13:00
@pmd-actions-helper

pmd-actions-helper Bot commented Jul 20, 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-21 18:51:58+00:00 for 2e23de6)

@adangel adangel changed the title [kotlin] Fix #6891: use KtModifiers container in AnnotationFqnAnnotator [kotlin] Fix #6891: Use KtModifiers container in AnnotationFqnAnnotator Jul 21, 2026

@adangel adangel 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.

Yes, sorry for that.

At least we have now a test for this functionality. I'll add another test case to verify, that the TypeName is on KtSingleAnnotation as well.

@adangel adangel added this to the 7.27.0 milestone Jul 21, 2026
@adangel
adangel merged commit d04ce54 into pmd:main Jul 21, 2026
13 checks passed
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.

[kotlin] AnnotationFqnAnnotator: @TypeName not set on UnescapedAnnotation nodes

2 participants