Repository navigation
GROOVY-12743: fix TraitComposer crash on closure-member annotations - #3278
Open
codeconsole wants to merge 1 commit into
Open
codeconsole wants to merge 1 commit into
codeconsole wants to merge 1 commit into
Conversation
createForwarderMethod passed Collections.emptyList() as the "not copied" list to GeneralUtils.copyAnnotatedNodeAnnotations, which adds every annotation with a closure member to that list, so any such annotation on a trait method with a body threw UnsupportedOperationException when a class implemented the trait. It now passes a real list, as createInterfaceStaticForwarder already does; the annotation stays on the trait method and the helper method and is, as before, not copied to the forwarder.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3278 +/- ##
==================================================
- Coverage 74.4140% 74.4115% -0.0025%
- Complexity 44379 44395 +16
==================================================
Files 1699 1699
Lines 151067 151150 +83
Branches 28790 28799 +9
==================================================
+ Hits 112415 112473 +58
- Misses 28380 28393 +13
- Partials 10272 10284 +12
🚀 New features to boost your workflow:
|
✅ All tests passed ✅🏷️ Commit: b52a20c Learn more about TestLens at testlens.app/docs. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes GROOVY-12743.
Any annotation whose member is given a closure, placed on a trait method with a body, crashed the compiler with
UnsupportedOperationExceptionfromAbstractList.addwhen a class implemented the trait.TraitComposer.createForwarderMethodpassedCollections.emptyList()as the "not copied" list toGeneralUtils.copyAnnotatedNodeAnnotations, which adds every annotation with a closure member to that list (the closure is still aClosureExpressionin canonicalization; it becomes a class only at class generation).TraitASTTransformation.createInterfaceStaticForwarderalready 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
@ThrowsIfand@Decreaseson a trait method hit this crash first; whether they can be enforced on a trait method is a separate question that GROOVY-12741 answers by rejecting them for now.Tests: a new test in
TraitASTTransformationTestcompiles 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.TraitASTTransformationTestpasses with the fix (294 tests), and so does thegroovy-contractsmodule.