-
Notifications
You must be signed in to change notification settings - Fork 421
Boolean variables in dataflow #6661
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f8b945a
Boolean expressions.
smillst 3d94083
Rename test case.
smillst 07050a9
Merge branch 'master' into issue406
smillst fcb5fa3
Supress warnings.
smillst 758edfe
Fix.
smillst 24b23f2
Merge remote-tracking branch 'origin/master' into issue406
smillst 99fdffc
Supress another warning.
smillst 4a5eb36
Checkpoint.
smillst f6f39ef
Add some javadoc.
smillst 9133f19
More suppressions.
smillst c67db02
Merge branch 'master' into issue406
smillst 712c91c
Fix daikon problem.
smillst 6cc2568
Skip job for now.
smillst 0e1abf2
Save the location of a crash in callTransfer.
smillst 11e8ef0
Merge branch 'error-location' into issue406
smillst 7197667
Allow for null.
smillst d54a83b
Add nullable.
smillst 3b10a0f
Merge remote-tracking branch 'origin/master' into issue406
smillst a227697
Tweaks.
smillst d1b4375
Merge ../checker-framework-branch-master into issue406
mernst 83a4d8d
Merge branch 'master' into issue406
mernst f753790
Typo fix
mernst ba40740
Typo fix
mernst 0b2575f
Rename `addStores` => `setStores`
mernst 557c899
Merge branch 'issue406' of github.com:smillst/checker-framework into …
smillst 976a3e4
Code review.
smillst 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
|
||
| public class Issue406 { | ||
| static class LocalDate {} | ||
|
|
||
| private void testFails1(@Nullable LocalDate x1, @Nullable LocalDate x2) { | ||
| boolean eitherIsNull = x1 == null || x2 == null; | ||
| if (eitherIsNull) return; | ||
| delegate(x1, x2); | ||
| } | ||
|
|
||
| private void testFails2(@Nullable LocalDate x1, @Nullable LocalDate x2) { | ||
| boolean firstIsNull = x1 == null; | ||
| boolean secondIsNull = x2 == null; | ||
| if (firstIsNull || secondIsNull) return; | ||
| delegate(x1, x2); | ||
| } | ||
|
|
||
| private void testWorks(@Nullable LocalDate x1, @Nullable LocalDate x2) { | ||
| if (x1 == null || x2 == null) return; | ||
| delegate(x1, x2); | ||
| } | ||
|
|
||
| private void delegate(LocalDate x1, LocalDate x2) { | ||
| // do something | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
checker/tests/optional/OptionalBooleanVariableFlowRefinement.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
| import org.checkerframework.checker.optional.qual.*; | ||
| import org.checkerframework.dataflow.qual.*; | ||
|
|
||
| @SuppressWarnings({"optional:parameter", "optional:field", "optional:collection"}) | ||
| class OptionalBooleanVariableFlowRefinement { | ||
|
|
||
| void validRefinementTest(Optional<String> opt) { | ||
| boolean optIsPresent = opt.isPresent(); | ||
| if (optIsPresent) { | ||
| opt.get(); // Legal | ||
| } | ||
| } | ||
|
|
||
| void otherValidRefinement(OptContainer container) { | ||
| boolean isGetLegal = | ||
| container.getOptStrs().isPresent() && !container.getOptStrs().get().isEmpty(); | ||
| if (isGetLegal) { | ||
| container.getOptStrs().get(); // Legal | ||
| } | ||
| } | ||
|
|
||
| class OptContainer { | ||
| private Optional<List<String>> strs; | ||
|
|
||
| public OptContainer(List<String> strs) { | ||
| this.strs = Optional.ofNullable(strs); | ||
| } | ||
|
|
||
| @Pure | ||
| public Optional<List<String>> getOptStrs() { | ||
| return this.strs; | ||
| } | ||
| } | ||
| } |
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
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
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
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.
What if one of
thisandotherhas a thenStore, but the other does not? What should be done in that case? The behavior is different than inmostSpecific()above, which always uses exactly one if either one is set.