GROOVY-12052: groovy-contracts @Ensures could support static methods#2573
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds groovy-contracts support for applying @Ensures postconditions to static methods, including result-based checks, while rejecting old state snapshots for static postconditions.
Changes:
- Allows static methods to be postcondition candidates.
- Generates an empty
oldmap for static postcondition plumbing and validatesoldusage as unsupported. - Adds regression tests for static postconditions and static
oldvalidation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
subprojects/groovy-contracts/src/main/java/org/apache/groovy/contracts/generation/CandidateChecks.java |
Removes the static-method exclusion for postcondition candidates. |
subprojects/groovy-contracts/src/main/java/org/apache/groovy/contracts/generation/PostconditionGenerator.java |
Adjusts old-variable setup for static postcondition generation. |
subprojects/groovy-contracts/src/main/java/org/apache/groovy/contracts/ast/visitor/AnnotationClosureVisitor.java |
Adds validation rejecting old references in static postconditions. |
subprojects/groovy-contracts/src/test/groovy/org/apache/groovy/contracts/tests/post/SimplePostconditionTests.groovy |
Adds GROOVY-12052 static postcondition tests. |
subprojects/groovy-contracts/src/test/groovy/org/apache/groovy/contracts/tests/other/ClosureExpressionValidationTests.groovy |
Adds validation coverage for unsupported old usage in static postconditions. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2573 +/- ##
==================================================
+ Coverage 68.1748% 68.1787% +0.0039%
+ Complexity 33161 33160 -1
==================================================
Files 1510 1510
Lines 126224 126230 +6
Branches 22893 22896 +3
==================================================
+ Hits 86053 86062 +9
+ Misses 32532 32529 -3
Partials 7639 7639
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
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.
No description provided.