[
https://issues.apache.org/jira/browse/GROOVY-12743?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18140820#comment-18140820
]
ASF GitHub Bot commented on GROOVY-12743:
-----------------------------------------
codecov-commenter commented on PR #3278:
URL: https://github.com/apache/groovy/pull/3278#issuecomment-6725257961
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3278?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 74.4115%. Comparing base
([`df1fe66`](https://app.codecov.io/gh/apache/groovy/commit/df1fe66ed134c0ec484117a526e2e8a420307e0b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`b52a20c`](https://app.codecov.io/gh/apache/groovy/commit/b52a20c686b9c6b4e318b8b20fb6028df7d48c1b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 2 commits behind head on master.
<details><summary>Additional details and impacted files</summary>
[](https://app.codecov.io/gh/apache/groovy/pull/3278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ 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
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3278?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
| Coverage Δ | |
|---|---|---|
|
[...codehaus/groovy/transform/trait/TraitComposer.java](https://app.codecov.io/gh/apache/groovy/pull/3278?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2Ftrait%2FTraitComposer.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS90cmFpdC9UcmFpdENvbXBvc2VyLmphdmE=)
| `82.3151% <100.0000%> (ø)` | |
... and [21 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3278/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test
Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests,
report on failures, and find test suite problems.
- :package: [JS Bundle
Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save
yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
> An annotation with a closure member on a trait method fails with
> UnsupportedOperationException in TraitComposer (seen with groovy-contracts
> @ThrowsIf and @Decreases)
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12743
> URL: https://issues.apache.org/jira/browse/GROOVY-12743
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 6.0.0
> Reporter: Scott Murphy Heiberg
> Priority: Major
>
> h3. Problem
> Any annotation whose member is given a closure, placed on a trait method with
> a body, crashes the compiler when a class implements the trait:
> {code:groovy}
> import java.lang.annotation.*
> @Retention(RetentionPolicy.RUNTIME)
> @Target(ElementType.METHOD)
> @interface Check { Class value() }
> trait T {
> @Check({ it > 0 }) int m() { 1 }
> }
> class C implements T {}
> {code}
> {noformat}
> General error during semantic analysis:
> java.lang.UnsupportedOperationException
> at java.base/java.util.AbstractList.add(AbstractList.java:155)
> at
> org.codehaus.groovy.ast.tools.GeneralUtils.copyAnnotatedNodeAnnotations(GeneralUtils.java:1867)
> at
> org.codehaus.groovy.transform.trait.TraitComposer.createForwarderMethod(TraitComposer.java:358)
> at
> org.codehaus.groovy.transform.trait.TraitComposer.applyTrait(TraitComposer.java:167)
> {noformat}
> The groovy-contracts annotations {{@ThrowsIf}} and {{@Decreases}} on a trait
> method with a body fail the same way. Reproduced on Groovy 6.0.0 and on
> master (df1fe66ed1).
> h3. Cause
> {{TraitComposer.createForwarderMethod}} passes an unmodifiable empty list as
> the "not copied" annotations to
> {{GeneralUtils.copyAnnotatedNodeAnnotations}}, with a comment that it should
> always stay empty. The closure of an annotation member is still a
> {{ClosureExpression}} in the canonicalization phase (it becomes a class only
> at class generation), so the helper adds the annotation to that list and
> {{AbstractList.add}} throws.
> {{TraitASTTransformation.createInterfaceStaticForwarder}} already uses a real
> list.
> h3. Fix
> {{TraitComposer}} uses a real list; the annotation stays on the trait method
> and the helper method and is, as before for closure members, not copied to
> the forwarder. Whether {{@ThrowsIf}} and {{@Decreases}} can then be enforced
> on a trait method is a groovy-contracts question (their transforms run after
> the trait transform has rewritten the body, so a condition that refers to
> trait state has no receiver in the helper class); GROOVY-12741 reports them
> as unsupported. Pull request to follow.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)