codeconsole opened a new pull request, #3278: URL: https://github.com/apache/groovy/pull/3278
Fixes [GROOVY-12743](https://issues.apache.org/jira/browse/GROOVY-12743). Any annotation whose member is given a closure, placed on a trait method with a body, crashed the compiler with `UnsupportedOperationException` from `AbstractList.add` when a class implemented the trait. `TraitComposer.createForwarderMethod` passed `Collections.emptyList()` as the "not copied" list to `GeneralUtils.copyAnnotatedNodeAnnotations`, which adds every annotation with a closure member to that list (the closure is still a `ClosureExpression` in canonicalization; it becomes a class only at class generation). `TraitASTTransformation.createInterfaceStaticForwarder` already passes a real list. The forwarder path now passes a real list as well. Behaviour is otherwise unchanged: the annotation stays on the trait method and the helper method and is, as before for closure members, not copied to the forwarder. The groovy-contracts annotations `@ThrowsIf` and `@Decreases` on a trait method hit this crash first; whether they can be enforced on a trait method is a separate question that [GROOVY-12741](https://issues.apache.org/jira/browse/GROOVY-12741) answers by rejecting them for now. Tests: a new test in `TraitASTTransformationTest` compiles a trait method carrying a closure-member annotation and checks the annotation on the trait and helper methods and its absence on the forwarder; it fails on master with the exception above. `TraitASTTransformationTest` passes with the fix (294 tests), and so does the `groovy-contracts` module. -- 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]
