Skip to content

GROOVY-12052: groovy-contracts @Ensures could support static methods#2573

Merged
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy12052
May 31, 2026
Merged

GROOVY-12052: groovy-contracts @Ensures could support static methods#2573
paulk-asert merged 1 commit into
apache:masterfrom
paulk-asert:groovy12052

Conversation

@paulk-asert
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 old map for static postcondition plumbing and validates old usage as unsupported.
  • Adds regression tests for static postconditions and static old validation.

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-commenter
Copy link
Copy Markdown

codecov-commenter commented May 31, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 68.1787%. Comparing base (b092f36) to head (51de8a2).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...ontracts/ast/visitor/AnnotationClosureVisitor.java 75.0000% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                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                
Files with missing lines Coverage Δ
...e/groovy/contracts/generation/CandidateChecks.java 63.3333% <ø> (-1.1828%) ⬇️
...y/contracts/generation/PostconditionGenerator.java 97.8723% <100.0000%> (+0.1451%) ⬆️
...ontracts/ast/visitor/AnnotationClosureVisitor.java 90.1695% <75.0000%> (-0.2085%) ⬇️

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

This comment has been minimized.

@paulk-asert paulk-asert merged commit 4a4986e into apache:master May 31, 2026
28 checks passed
@paulk-asert paulk-asert deleted the groovy12052 branch May 31, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants