Repository navigation
GROOVY-12843: check contracts on interface methods with a body - #3371
Open
paulk-asert wants to merge 1 commit into
Open
paulk-asert wants to merge 1 commit into
paulk-asert wants to merge 1 commit into
Conversation
A @requires or @ensures on a default or static interface method was woven into the method, but the check reads a $GCONTRACTS_ENABLED field that was added only to classes: every call failed with a missing property, and static compilation was refused. An interface with a concrete method now has the field, and the check reads it from the interface. A postcondition also called the old-variables method, which only a class compiled with contracts has, and which holds that class's fields. In an interface method with a body, old.name is now the entry value of a parameter or of a property of the interface, read through its getter, so lambdas, coerced maps and Java classes work however they store it. Any other name is a compile error. A name used only by a postcondition inherited from a separately compiled interface cannot be seen by the compiler; reading it throws an exception that says so.
🚨 TestLens detected 2 failed tests 🚨Test SummaryTip Inspect all details with the TestLens CLI: Build and test / lts (25, ubuntu-latest) > :test
🏷️ Commit: 6ee1060 Test FailuresGrabResolverTest > testResolverDefinitionResolvesDependency() (:test in Build and test / lts (25, ubuntu-latest))GrabResolverTest > testResolverDefinitionResolvesDependencyWithShorthand() (:test in Build and test / lts (25, ubuntu-latest))Rerun ControlsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #3371 +/- ##
==================================================
+ Coverage 75.2860% 75.2954% +0.0095%
- Complexity 49967 50000 +33
==================================================
Files 1775 1776 +1
Lines 163660 163731 +71
Branches 32301 32328 +27
==================================================
+ Hits 123213 123282 +69
Misses 28947 28947
- Partials 11500 11502 +2
🚀 New features to boost your workflow:
|
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.
A @requires or @ensures on a default or static interface method was woven into the method, but the check reads a $GCONTRACTS_ENABLED field that was added only to classes: every call failed with a missing property, and static compilation was refused. An interface with a concrete method now has the field, and the check reads it from the interface.
A postcondition also called the old-variables method, which only a class compiled with contracts has, and which holds that class's fields. In an interface method with a body, old.name is now the entry value of a parameter or of a property of the interface, read through its getter, so lambdas, coerced maps and Java classes work however they store it. Any other name is a compile error. A name used only by a postcondition inherited from a separately compiled interface cannot be seen by the compiler; reading it throws an exception that says so.