-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Delegation Checker #6609
Draft
jyoo980
wants to merge
174
commits into
typetools:master
Choose a base branch
from
jyoo980:yoo/standalone-delegation-checker
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add Delegation Checker #6609
Changes from 173 commits
Commits
Show all changes
174 commits
Select commit
Hold shift + click to select a range
dddb8a3
Add start of manual for Non-Empty Checker
jyoo980 f5b1188
Add section on Non-Empty Checker checks
jyoo980 d7e07e7
Adding type hierarchy image
jyoo980 ce3cde3
Add qualifiers and barebones Non-Empty Checker
jyoo980 61ce733
Add documentation for quals
jyoo980 e20d5af
Add postcondition annotations for the Non-Empty Checker
jyoo980 1a13283
Merge branch 'master' into yoo/nonempty-checker
jyoo980 93bc49e
Merge branch 'typetools:master' into yoo/nonempty-checker
jyoo980 433a993
Add postcondition annotations and tests
jyoo980 5fe370d
Merge branch 'yoo/nonempty-checker' of github.com:jyoo980/checker-fra…
jyoo980 53ef7e7
Merge branch 'typetools:master' into yoo/nonempty-checker
jyoo980 134aef7
Fix Javadoc build errors
jyoo980 cdf043d
Add formatting updates
jyoo980 eda22bb
Adding descriptions for `@EnsuresNonEmpty` and `@EnsuresNonEmptyIf`
jyoo980 8824de7
Adding tests for `@EnsuresNonEmpty` and `@EnsuresNonEmptyIf`
jyoo980 5aeea64
Tweaks to manual
mernst b9699e1
Merge branch 'yoo/nonempty-checker' of github.com:jyoo980/checker-fra…
mernst 500c249
Update formatting and code example
jyoo980 9e58eaf
Merge branch 'typetools:master' into yoo/nonempty-checker
jyoo980 c170355
Add `NonEmptyBottom` and `PolyNonEmpty` to Non-Empty type system
jyoo980 1e66676
Re-organize tests
jyoo980 fc61d3d
Adding additional tests for `Set`
jyoo980 e91c373
Add temporary `@skip-test`
jyoo980 6fdfc3b
Merge branch 'typetools:master' into yoo/nonempty-checker
jyoo980 e7fd519
Merge branch 'master' into yoo/nonempty-checker
jyoo980 00714bc
Merge ../checker-framework-fork-jyoo980-branch-yoo-nonempty-checker i…
mernst 4467854
Set `this.sideEffectsUnrefineAliases` in NonEmptyAnnotatedTypeFactory
mernst 20055de
Merge ../checker-framework-branch-master into yoo/nonempty-checker
mernst 98f218c
Merge branch 'yoo/nonempty-checker' of github.com:jyoo980/checker-fra…
mernst 2c5e9ff
Merge ../checker-framework-fork-jyoo980-branch-yoo-nonempty-checker i…
mernst 99b9242
Merge pull request #1 from mernst/issue6407
jyoo980 f80abb2
Merge branch 'master' into yoo/nonempty-checker
jyoo980 db6dab9
Add test for `Set.remove(E)`
jyoo980 89b4bee
Add tests for immutable map operations
jyoo980 a9964bc
Merge branch 'typetools:master' into yoo/nonempty-checker
jyoo980 19a2042
Enable JDK tests
jyoo980 90de18e
Merge branch 'yoo/nonempty-checker' of github.com:jyoo980/checker-fra…
jyoo980 a0da89d
Apply Spotless changes
jyoo980 ee28483
Merge branch 'typetools:master' into yoo/nonempty-checker
jyoo980 bca7308
Merge branch 'master' into yoo/nonempty-checker
jyoo980 a53b9ba
Adding tests for iterator operations
jyoo980 d788fe4
Merge branch 'master' into yoo/nonempty-checker
jyoo980 28859fb
Start implementing transfer fn. for Non-Empty Checker
jyoo980 266af5f
Implement `NonEmptyTransfer.visitNotEqual`
jyoo980 16d8aa1
Pass proper arg
jyoo980 aec4317
Complete initial impl. of transfer function for Non-Empty Checker
jyoo980 3fefdb4
Adding failing tests for LTE
jyoo980 e44ecb8
Comparison refinement working, need to add documentation
jyoo980 de84e5e
Merge branch 'master' into yoo/nonempty-checker
jyoo980 fefadec
Document `NonEmptyTransfer` class
jyoo980 feb14e2
Invert conditionals and comment-out tests
jyoo980 10ddf62
Update Map.java annotation tests
jyoo980 92dee7b
Add support for `Map.size` in `NonEmptyTransfer`
jyoo980 a9b7069
Add switch test case
jyoo980 cd8d5e1
Add transfer function for switch statments
jyoo980 f079ad5
Merge branch 'master' into yoo/nonempty-checker
jyoo980 5d5cf3a
Support refinement for equality comparisons
jyoo980 a107fb2
Implement implicit Non-Empty refinement for Equals
jyoo980 2c4dc9b
Merge branch 'master' into yoo/nonempty-checker
jyoo980 6fc9073
Implement implicit refinement for `NotEqualTo` expressions
jyoo980 0718311
Merge branch 'master' into yoo/nonempty-checker
jyoo980 f45e835
Add todo for GLB in strengthening annos
jyoo980 1c37e41
Test that `Predicate.test` is pure
mernst 2a68280
Merge branch 'yoo/nonempty-checker' of github.com:jyoo980/checker-fra…
mernst b567d3c
Merge branch 'master' into yoo/nonempty-checker
jyoo980 ed46d30
Instantiate `NonEmptyTransfer` via reflection
jyoo980 d72f6bd
Implement refinement for `java.util.List indexOf(Object)`
jyoo980 0660188
Implement `indexOf(Object)` refinement for `switch` statements
jyoo980 692b0c4
Add test case
mernst ac242c2
Add test case for `size()` call in `isEmpty()`
jyoo980 0c87474
Update code example in manual
jyoo980 3eceeda
Add manual section and test case for delegation
jyoo980 649f386
Add type annos for Delegation checking
jyoo980 f413c61
Merge branch 'master' into yoo/nonempty-checker
jyoo980 d67005d
Simplify `@Delegate` logic
jyoo980 8cb8fd3
Add basic `DelegationChecker` implementation
jyoo980 2174fb7
Remove override for `setRoot` as it appears to crash with NPE
jyoo980 5d472ae
Merge branch 'master' into yoo/nonempty-checker
jyoo980 349f825
Make `NonEmptyChecker` extend `DelegationChecker`
jyoo980 82ec19e
Add test case for invalid delegation
jyoo980 ff710d5
Implement very basic delegation verification
jyoo980 3350681
Simplify logic for finding `Override` annotations
jyoo980 6dbab9a
Update tests
jyoo980 3c783c6
Document code
jyoo980 583bdab
Merge remote-tracking branch 'upstream/master' into yoo/nonempty-checker
jyoo980 f8b5c9f
Fix boolean operator
jyoo980 471b30d
Support delgation to void methods
jyoo980 451b831
Merge branch 'master' into yoo/nonempty-checker
jyoo980 a3c967f
Allow exceptional exits for delegate methods
jyoo980 d3a3900
Merge remote-tracking branch 'upstream/master' into yoo/nonempty-checker
jyoo980 dfb58b9
Start obtaining methods from supertype
jyoo980 44d0b51
Add UnmodifiableTest.java
jyoo980 1c7d8d4
Expand diagnostics, expand test
mernst e96fcf5
Adding test case for `Collections.java`
jyoo980 896b727
Fix merge
jyoo980 353b096
Merge branch 'master' into yoo/nonempty-checker
jyoo980 e6fe54a
Comment-out erroneous override checking
jyoo980 c65f2fc
Implement naive override checking
jyoo980 8cdcf6d
Add `@DelegatorMustOverride` annotation
jyoo980 91f127a
Merge branch 'master' into yoo/nonempty-checker
jyoo980 b00303c
Add Non-Empty Checker tree annotator for `NewArrayTree`
jyoo980 d0c3ae6
Add test case for `Map.ofEntries`
jyoo980 01fbe18
Merge branch 'master' into yoo/nonempty-checker
jyoo980 7156364
Add test cases for `Stream.java`
jyoo980 9a13edc
Merge branch 'master' into yoo/nonempty-checker
jyoo980 074f638
Comments
mernst 3a782c0
Merge branch 'master' into yoo/nonempty-checker
jyoo980 44c72dd
Merge branch 'master' into yoo/nonempty-checker
jyoo980 e385d0e
Merge remote-tracking branch 'upstream/master' into yoo/nonempty-checker
jyoo980 2b3cd4b
Add WIP for resolving false positives with non-empty streams
jyoo980 1ba6043
Refine the result, not the receiver
mernst c3478c2
Fix typo in documentation
jyoo980 25ad3c4
Merge branch 'master' into yoo/nonempty-checker
jyoo980 c044594
Merge remote-tracking branch 'upstream/master' into yoo/nonempty-checker
jyoo980 7b70a61
Add support for `Stream.reduce(BinaryOperator)`
jyoo980 3a5c8db
Merge branch 'master' into yoo/nonempty-checker
jyoo980 6d8dcc5
Add support for `Stream.findAny` and `Stream.findFirst`
jyoo980 2618787
Merge remote-tracking branch 'upstream/master' into yoo/nonempty-checker
jyoo980 d08e2ec
Handle case where receiver may be null
jyoo980 22cd54d
Merge branch 'master' into yoo/nonempty-checker
jyoo980 9e1028d
Merge branch 'master' into yoo/nonempty-checker
jyoo980 4a18b42
Merge remote-tracking branch 'upstream/master' into yoo/nonempty-checker
jyoo980 3fda942
Merge remote-tracking branch 'upstream/master' into yoo/nonempty-checker
jyoo980 a945675
Apply Spotless changes
jyoo980 b7d7e17
Merge w. master
jyoo980 613986d
Merge branch 'master' into yoo/nonempty-checker
jyoo980 763df84
Merge branch 'master' into yoo/nonempty-checker
jyoo980 eafc977
Merge branch 'master' into yoo/nonempty-checker
jyoo980 7103274
Merge branch 'master' into yoo/nonempty-checker
jyoo980 bb26689
Merge branch 'master' into yoo/nonempty-checker
jyoo980 4264e4d
Merge branch 'master' into yoo/nonempty-checker
jyoo980 ef1eec2
Refine types in OptionalTransfer without NonEmptyAnnotatedTypeFactory
jyoo980 6a89910
Add debugging information
jyoo980 4d09502
Merge branch 'typetools:master' into yoo/nonempty-optional-transfer-n…
jyoo980 5b2056e
Apply lint
jyoo980 7c3527d
Merge branch 'master' into yoo/nonempty-optional-transfer-nonempty-in…
jyoo980 50bfa36
Reading @NonEmpty anno in Optional Transfer
jyoo980 b5adf0d
Add documentation and debug logs
jyoo980 a0abd2f
Add additional logging
jyoo980 05b15d0
Remove unnecessary helper methods
jyoo980 b1ed401
Merge branch 'master' into yoo/nonempty-optional-transfer-nonempty-in…
jyoo980 f8ba782
Merge branch 'typetools:master' into yoo/nonempty-optional-transfer-n…
jyoo980 f5b1614
Merge branch 'master' into yoo/nonempty-optional-transfer-nonempty-in…
jyoo980 21e21f2
Refactoring check for non-empty method invocation receiver
jyoo980 38c5402
Get initial receiver of method invocation
jyoo980 fb2bb56
Enable insertion of non-deterministic expressions into the store
jyoo980 7d695da
Clean up logging
jyoo980 75fd8fa
Start implementing method-level support for `skipDefs` flag
jyoo980 7fa7d4a
Merge branch 'master' into yoo/skipdefs-for-methods
jyoo980 a8248cc
Correct logic for `JavaExpression.getInitialReceiverOfMethodInvocation`
jyoo980 9887291
Add debug logs
jyoo980 8e91f0d
Enable `NonEmptyChecker` to access methods to check from the `Optiona…
jyoo980 e7906b0
Stub implementation of `SourceChecker.shouldSkipDefs` and make it non…
jyoo980 14c7977
Remove unnecessary flags
jyoo980 0478e43
Merge branch 'yoo/skipdefs-for-methods' into yoo/nonempty-optional-tr…
jyoo980 6d65157
Simplify logic for accessing + checking methods to check in the Non-E…
jyoo980 89d3861
Update algorithm to obtain methods to check with Non-Empty Checker
jyoo980 fa1539c
Merge branch 'master' into yoo/nonempty-optional-transfer-nonempty-in…
jyoo980 0f53325
Merge branch 'master' into yoo/nonempty-optional-transfer-nonempty-in…
jyoo980 9a67aab
Override `processMethod`
jyoo980 46a2725
Account for case when `TreeUtils.getReceiverTree` returns the receive…
jyoo980 572584d
Handle receivers of stream operations that are fields, not locals or …
jyoo980 c0c04a0
Merge ../checker-framework-branch-master into yoo/nonempty-optional-t…
mernst 64c469b
Use `%n`, not `\n`, for platform independence
mernst 615205d
Minor changes
mernst 6654033
Remove changes related to the Optional Checker
jyoo980 878ffeb
Remove Non-Empty related code
jyoo980 6ec0516
Start of Standalone Delegation Checker
jyoo980 5c65841
Remove unrelated changes
jyoo980 afe12cc
Remove additional unrelated code
jyoo980 87f8e0e
Remove manual entry
jyoo980 36ebf2e
Add back `TreeUtils.fieldsFromTree`
jyoo980 06d74b1
Extracting delegation checking logic into `DelegationVisitor`
jyoo980 95c3a8f
Merge remote-tracking branch 'typetools/master' into yoo/standalone-d…
jyoo980 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
checker-qual/src/main/java/org/checkerframework/common/delegation/qual/Delegate.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.checkerframework.common.delegation.qual; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* This is an annotation that indicates a field is a delegate, fields are not delegates by default. | ||
* | ||
* <p>Here is a way that this annotation may be used: | ||
* | ||
* <pre><code> | ||
* class MyEnumeration<T> implements Enumeration<T> { | ||
* {@literal @}Delegate | ||
* private Enumeration<T> e; | ||
* | ||
* public boolean hasMoreElements() { | ||
* return e.hasMoreElements(); | ||
* } | ||
* } | ||
* </code></pre> | ||
* | ||
* In the example above, {@code MyEnumeration.hasMoreElements()} delegates a call to {@code | ||
* e.hasMoreElements()}. | ||
* | ||
* @checker_framework.manual #non-empty-checker Non-Empty Checker | ||
*/ | ||
@Documented | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD}) | ||
public @interface Delegate {} |
49 changes: 49 additions & 0 deletions
49
...qual/src/main/java/org/checkerframework/common/delegation/qual/DelegatorMustOverride.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package org.checkerframework.common.delegation.qual; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* This is an annotation that indicates a method that <i>must</i> be overridden in order for a | ||
* conditional postcondition to hold for a delegating class. | ||
* | ||
* <p>Here is a way that this annotation may be used: | ||
* | ||
* <p>Given a class that declares a method with a postcondition annotation: | ||
* | ||
* <pre><code> | ||
* class ArrayListVariant<T> { | ||
* {@literal @}EnsuresPresentIf(result = true) | ||
* {@literal @}DelegatorMustOverride | ||
* public boolean hasMoreElements() { | ||
* return e.hasMoreElements(); | ||
* } | ||
* } | ||
* </code></pre> | ||
* | ||
* A delegating client <i>must</i> override the method: | ||
* | ||
* <pre><code> | ||
* class MyArrayListVariant<T> extends ArrayListVariant<T> { | ||
* | ||
* {@literal @}Delegate | ||
* private ArrayListVariant<T> myList; | ||
* | ||
* | ||
* {@literal @}Override | ||
* {@literal @}EnsuresPresentIf(result = true) | ||
* public boolean hasMoreElements() { | ||
* return myList.hasMoreElements(); | ||
* } | ||
* } | ||
* </code></pre> | ||
* | ||
* Otherwise, a warning will be raised. | ||
* | ||
* @checker_framework.manual #non-empty-checker Non-Empty Checker | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.METHOD}) | ||
public @interface DelegatorMustOverride {} |
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
22 changes: 22 additions & 0 deletions
22
.../src/main/java/org/checkerframework/common/delegation/DelegationAnnotatedTypeFactory.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.checkerframework.common.delegation; | ||
|
||
import java.lang.annotation.Annotation; | ||
import java.util.Set; | ||
import org.checkerframework.common.basetype.BaseAnnotatedTypeFactory; | ||
import org.checkerframework.common.basetype.BaseTypeChecker; | ||
import org.checkerframework.common.delegation.qual.Delegate; | ||
|
||
/** Annotated type factory for the Delegation Checker. */ | ||
public class DelegationAnnotatedTypeFactory extends BaseAnnotatedTypeFactory { | ||
|
||
/** Create the type factory. */ | ||
public DelegationAnnotatedTypeFactory(BaseTypeChecker checker) { | ||
super(checker); | ||
this.postInit(); | ||
} | ||
|
||
@Override | ||
protected Set<Class<? extends Annotation>> createSupportedTypeQualifiers() { | ||
return getBundledTypeQualifiers(Delegate.class); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
framework/src/main/java/org/checkerframework/common/delegation/DelegationChecker.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.checkerframework.common.delegation; | ||
|
||
import com.sun.source.tree.*; | ||
import java.util.*; | ||
import javax.lang.model.element.*; | ||
import org.checkerframework.common.basetype.BaseTypeChecker; | ||
import org.checkerframework.common.delegation.qual.Delegate; | ||
|
||
/** | ||
* This class enforces checks for the {@link Delegate} annotation. | ||
* | ||
* <p>It is not a checker for a type system. It enforces the following syntactic checks: | ||
* | ||
* <ul> | ||
* <li>A class may have up to exactly one field marked with the {@link Delegate} annotation. | ||
* <li>An overridden method's implementation must be exactly a call to the delegate field. | ||
* <li>A class overrides <i>all</i> methods declared in its superclass. | ||
* </ul> | ||
*/ | ||
public class DelegationChecker extends BaseTypeChecker {} | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to extend
SourceChecker
.