Repository navigation
Conversation
…p type Assisted-by: Claude Code (Claude Opus 5.5)
902743e to
4fed239
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## GROOVY_5_1_X #3352 +/- ##
======================================================
- Coverage 67.3669% 67.3644% -0.0025%
+ Complexity 29767 29763 -4
======================================================
Files 1384 1384
Lines 117384 117384
Branches 20677 20677
======================================================
- Hits 79078 79075 -3
- Misses 31742 31748 +6
+ Partials 6564 6561 -3
🚀 New features to boost your workflow:
|
|
Thanks @swampie for the clear report, the reproducer and the regression test. They made this much easier to track down. We've gone with a different fix from the GROOVY-11838 backport, so I'll close this PR, but your test commit has been included with you as the author. Root cause on 5.x. @NamedParam is repeatable, so ExtendedVerifier wraps the repeated annotations in an implicit @NamedParams container. On 5.x that container node never reads its own @target(PARAMETER). It falls back to "all targets", which includes TYPE_USE, so it gets copied onto the Map parameter's type. That type node is shared, so each @MapConstructor class adds another copy, and you end up with the duplicate type annotations. Why not backport GROOVY-11838. It hides the problem by narrowing the default targets for every annotation without @target. That would make some code that compiles on 5.1.x today fail to compile, which we'd rather avoid in a patch release. The fix we've used reads the container's declared targets. It's a two-line change in ExtendedVerifier, and default target handling on 5.x stays as it is. What landed where:
If you get a chance, it would be great to hear whether a 5.1.4 snapshot clears the duplicates on your ~8,500-class application. Thanks again! |
Backport of 71b6eb9 (GROOVY-11838, already on master) to
GROOVY_5_1_X, to fix GROOVY-12787.On 5.x, a compilation unit with several
@MapConstructorclasses gives each generatedMapconstructor duplicate@NamedParamstype annotations. Reflecting on the constructor throwsAnnotationFormatError, and the@NamedParamsit reports can list another class's parameters. GROOVY-11838 makes an annotation without@Targetapply to no type contexts (JLS 9.6.4.1), so@NamedParamsis no longer copied onto the sharedMaptype. 4.0.x and 6.0.x are not affected.Commits:
AnnotationNodeis identical to master.AnnotationNodeTestdoes not exist on this branch, so the commit creates it with master'stestIsTargetAllowedmethod (JUnit 5).MapConstructorTransformTest.testNamedParamsAreNotCopiedOntoSharedMapTypefor GROOVY-12787. It fails without the fix (AnnotationFormatError: Duplicate annotation ... NamedParams) and passes with it.Testing:
./gradlew test: 16,616 tests, 0 failures, 79 skipped.Behaviour change, same as on master: annotations without
@Targetare no longer accepted in type-use positions.The GROOVY-12787 regression test is new and is not on master. Should I open a separate pull request adding it to master too?