swampie opened a new pull request, #3352: URL: https://github.com/apache/groovy/pull/3352
Backport of 71b6eb9a53 (GROOVY-11838) to `GROOVY_5_1_X`, to fix [GROOVY-12787](https://issues.apache.org/jira/browse/GROOVY-12787). On 5.x, a compilation unit with several `@MapConstructor` classes gives each generated `Map` constructor duplicate `@NamedParams` type annotations. Reflecting on the constructor throws `AnnotationFormatError`, and the `@NamedParams` it reports can list another class's parameters. GROOVY-11838 makes an annotation without `@Target` apply to no type contexts (JLS 9.6.4.1), so `@NamedParams` is no longer copied onto the shared `Map` type. 4.0.x and 6.0.x are not affected. Commits: - ce4e3f1996: the GROOVY-11838 change. `AnnotationNode` is identical to master. `AnnotationNodeTest` does not exist on this branch, so the commit creates it with the same `testIsTargetAllowed` method, using JUnit 4 like the other 5.1.x tests. - 902743e5de: adds `MapConstructorTransformTest.testNamedParamsAreNotCopiedOntoSharedMapType` for GROOVY-12787. It fails without the fix (`AnnotationFormatError: Duplicate annotation ... NamedParams`) and passes with it. Testing: - `./gradlew :test --tests '*Annotation*' --tests '*MapConstructor*' --tests '*NamedParam*'`: 1,434 tests, 0 failures, 2 skipped. - The reproducer from GROOVY-12787 fails on 5.1.3 and passes with this change. - On an application of about 8,500 classes compiled with the 5.1.4 snapshot, this removes all remaining duplicate type annotations (157 classes before). Behaviour change, same as on master: annotations without `@Target` are no longer accepted in type-use positions. -- 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]
