paulk-asert commented on PR #3352:
URL: https://github.com/apache/groovy/pull/3352#issuecomment-7131552554

   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:
   - master and GROOVY_6_0_X: your 
testNamedParamsAreNotCopiedOntoSharedMapType, plus a test for an implicit 
container with an explicit, narrower @Target. These are tests only: 
GROOVY-11884 already reads @Target from the annotation class there, so neither 
branch has the bug. That also answers your question about adding the test to 
master.
   - GROOVY_5_1_X: the ExtendedVerifier fix plus both tests (<5.1 commit 
SHAs>). Both tests fail on 5.1 without the fix and pass with it. This will be 
in 5.1.4.
   
   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!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to