You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "paulk-asert (via GitHub)" <gi...@apache.org> on 2026/07/07 01:41:50 UTC

[PR] GROOVY-12136: groovy-contracts: allow @Requires to opt out of weaving… [groovy]

paulk-asert opened a new pull request, #2672:
URL: https://github.com/apache/groovy/pull/2672

   … the contract


-- 
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: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-12136: groovy-contracts: allow @Requires to opt out of weaving… [groovy]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #2672:
URL: https://github.com/apache/groovy/pull/2672#issuecomment-4899556082

   ## [Codecov](https://app.codecov.io/gh/apache/groovy/pull/2672?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :x: Patch coverage is `87.50000%` with `2 lines` in your changes missing coverage. Please review.
   :white_check_mark: Project coverage is 68.5870%. Comparing base ([`7b3c77f`](https://app.codecov.io/gh/apache/groovy/commit/7b3c77f78818579d4ff193f6abfdb6a2462a81c6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`2cd8e1f`](https://app.codecov.io/gh/apache/groovy/commit/2cd8e1f2e19ba07a2c75f451dca1ccc4dca9daf0?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.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/groovy/pull/2672?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
   |---|---|---|
   | [...che/groovy/contracts/generation/BaseGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&filepath=subprojects%2Fgroovy-contracts%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fcontracts%2Fgeneration%2FBaseGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNvbnRyYWN0cy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ3Jvb3Z5L2NvbnRyYWN0cy9nZW5lcmF0aW9uL0Jhc2VHZW5lcmF0b3IuamF2YQ==) | 88.8889% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   | [...vy/contracts/generation/PreconditionGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&filepath=subprojects%2Fgroovy-contracts%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fcontracts%2Fgeneration%2FPreconditionGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNvbnRyYWN0cy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ3Jvb3Z5L2NvbnRyYWN0cy9nZW5lcmF0aW9uL1ByZWNvbmRpdGlvbkdlbmVyYXRvci5qYXZh) | 0.0000% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   [![Impacted file tree graph](https://app.codecov.io/gh/apache/groovy/pull/2672/graphs/tree.svg?width=650&height=150&src=pr&token=1r45138NfQ&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
   
   ```diff
   @@                Coverage Diff                 @@
   ##               master      #2672        +/-   ##
   ==================================================
   + Coverage     68.5752%   68.5870%   +0.0118%     
   - Complexity      33857      33868        +11     
   ==================================================
     Files            1528       1528                
     Lines          128319     128332        +13     
     Branches        23322      23326         +4     
   ==================================================
   + Hits            87995      88019        +24     
   + Misses          32508      32503         -5     
   + Partials         7816       7810         -6     
   ```
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/groovy/pull/2672?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...tracts/ast/visitor/AnnotationProcessorVisitor.java](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&filepath=subprojects%2Fgroovy-contracts%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fcontracts%2Fast%2Fvisitor%2FAnnotationProcessorVisitor.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNvbnRyYWN0cy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ3Jvb3Z5L2NvbnRyYWN0cy9hc3QvdmlzaXRvci9Bbm5vdGF0aW9uUHJvY2Vzc29yVmlzaXRvci5qYXZh) | `89.5652% <100.0000%> (+0.4743%)` | :arrow_up: |
   | [...y/contracts/generation/PostconditionGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&filepath=subprojects%2Fgroovy-contracts%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fcontracts%2Fgeneration%2FPostconditionGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNvbnRyYWN0cy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ3Jvb3Z5L2NvbnRyYWN0cy9nZW5lcmF0aW9uL1Bvc3Rjb25kaXRpb25HZW5lcmF0b3IuamF2YQ==) | `96.6102% <100.0000%> (ø)` | |
   | [...che/groovy/contracts/generation/BaseGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&filepath=subprojects%2Fgroovy-contracts%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fcontracts%2Fgeneration%2FBaseGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNvbnRyYWN0cy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ3Jvb3Z5L2NvbnRyYWN0cy9nZW5lcmF0aW9uL0Jhc2VHZW5lcmF0b3IuamF2YQ==) | `92.1875% <88.8889%> (-0.6696%)` | :arrow_down: |
   | [...vy/contracts/generation/PreconditionGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2672?src=pr&el=tree&filepath=subprojects%2Fgroovy-contracts%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fcontracts%2Fgeneration%2FPreconditionGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VicHJvamVjdHMvZ3Jvb3Z5LWNvbnRyYWN0cy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvZ3Jvb3Z5L2NvbnRyYWN0cy9nZW5lcmF0aW9uL1ByZWNvbmRpdGlvbkdlbmVyYXRvci5qYXZh) | `83.8710% <0.0000%> (+6.4516%)` | :arrow_up: |
   
   ... and [5 files with indirect coverage changes](https://app.codecov.io/gh/apache/groovy/pull/2672/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>


-- 
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: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-12136: groovy-contracts: allow @Requires to opt out of weaving… [groovy]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2672:
URL: https://github.com/apache/groovy/pull/2672#discussion_r3533058955


##########
subprojects/groovy-contracts/src/main/java/org/apache/groovy/contracts/generation/BaseGenerator.java:
##########
@@ -187,6 +187,14 @@ protected BlockStatement wrapAssertionBooleanExpression(ClassNode type, MethodNo
      */
     protected BooleanExpression addCallsToSuperMethodNodeAnnotationClosure(final ClassNode type, final MethodNode methodNode, final Class<? extends Annotation> annotationType, BooleanExpression booleanExpression, boolean isPostcondition) {
         List<AnnotationNode> contractElementAnnotations = AnnotationUtils.getAnnotationNodeInHierarchyWithMetaAnnotation(type.getSuperClass(), methodNode, ClassHelper.makeWithoutCaching(annotationType));
+        if (!isPostcondition) {
+            // An unwoven precondition (@Requires(woven = false)) never contributes to generated
+            // assertions — inherited arms included, so an override does not weave a check its
+            // declaring class deliberately left to existing enforcement.
+            contractElementAnnotations = contractElementAnnotations.stream()
+                    .filter(a -> !isUnwoven(a))
+                    .collect(java.util.stream.Collectors.toList());
+        }
         if (contractElementAnnotations.isEmpty()) {
             methodNode.putNodeMetaData(META_DATA_USE_INLINE_MODE, Boolean.TRUE);
         } else {

Review Comment:
   `META_DATA_USE_INLINE_MODE` is only ever set to `true` and never cleared when inherited contract annotations are present. Since preconditions are injected before postconditions (DomainModelInjectionVisitor), enabling inline mode while processing preconditions can incorrectly cause postcondition weaving to take the inline path even when inherited postconditions exist, which would skip inherited postcondition checks. With the new unwoven-precondition filtering, more methods will hit the “empty inherited preconditions” path and set this flag, increasing the risk of this cross-contamination.



-- 
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: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-12136: groovy-contracts: allow @Requires to opt out of weaving… [groovy]

Posted by "testlens-app[bot] (via GitHub)" <gi...@apache.org>.
testlens-app[bot] commented on PR #2672:
URL: https://github.com/apache/groovy/pull/2672#issuecomment-4899642556

   ## ✅ All tests passed ✅
   
   🏷️ Commit: 2cd8e1f2e19ba07a2c75f451dca1ccc4dca9daf0
   ▶️ Tests:  102755 executed
   ⚪️ Checks: 31/31 completed
   
   ---
   _Learn more about TestLens at [testlens.app](https://testlens.app)._
   


-- 
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: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] GROOVY-12136: groovy-contracts: allow @Requires to opt out of weaving… [groovy]

Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert merged PR #2672:
URL: https://github.com/apache/groovy/pull/2672


-- 
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: notifications-unsubscribe@groovy.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org