-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for static fields in contracts (#1118)
This PR adds support for static fields in `@EnsureNonnull`,`EnsureNonnullIf`,`@RequiresNonnull` annotations. Currently the following code will throw validation errors (as well as the annotation handlers are unable to handle static fields). However, after this change, static fields for all three annotations are supported ``` class Foo { @nullable static Item staticNullableItem; @EnsuresNonNull("staticNullableItem") public static void initializeStaticField() { staticNullableItem = new Item(); } @RequiresNonNull("staticNullableItem") public static void useStaticField() { staticNullableItem.call(); } @EnsuresNonNullIf(value="staticNullableItem", result=true) public static boolean hasStaticNullableItem() { return staticNullableItem != null; } } ``` Fixes #431 --------- Co-authored-by: Manu Sridharan <msridhar@gmail.com>
- Loading branch information
1 parent
43054bb
commit aaf9f08
Showing
8 changed files
with
354 additions
and
25 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.