forked from typetools/checker-framework
-
Notifications
You must be signed in to change notification settings - Fork 29
Improve cast warnings/errors logic #337
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 all commits
Commits
Show all changes
63 commits
Select commit
Hold shift + click to select a range
298df8a
add downcast to cf
AndrewShf c4588df
add downcast to cf
AndrewShf 82740f7
add downcast/incomparable cast to cf
AndrewShf d71ead6
use getEffectiveAnnotation
AndrewShf 0dec947
check the java type down cast
AndrewShf f5c5d22
revert typo fix, fix in another pr
AndrewShf c916493
add incomparable cast message key
AndrewShf bfa5794
replace some warnings with incompatible cast errors
AndrewShf 93a6a1a
refined the approach when casting T to T
AndrewShf b04007c
suppress some warnings
AndrewShf 9b116a7
refine the logic to cast from T to T
AndrewShf b88949f
add method documentation
AndrewShf 361f487
remove useless for loop
AndrewShf 874e594
update mustcallvisitor, signedness visitor
AndrewShf 09904ba
Merge branch 'master' into eisop_typecast
wmdietl 9862649
Merge branch 'master' into eisop_typecast
wmdietl b8f1549
Merge remote-tracking branch 'eisop/master' into eisop_typecast
AndrewShf deffd1d
add one test file and improve documentation
AndrewShf 4f476f2
move testfile to another directory
AndrewShf f82dc77
fix testcase
AndrewShf efeeea2
fix testcase
AndrewShf c34285f
improve naming in the error message
AndrewShf 16d69a6
add comments
AndrewShf 4cd7e9a
Merge branch 'master' into eisop_typecast
wmdietl cb0cb64
Merge branch 'master' into eisop_typecast
wmdietl d7429e4
solve field shadowing
AndrewShf 8502489
update error messages
AndrewShf 72e074e
simplify branches
AndrewShf 1cfd105
update
AndrewShf e92f0c6
Merge branch 'master' into eisop_typecast
wmdietl 0658def
Merge branch 'master' into eisop_typecast
wmdietl 7991a8b
merge with eisop master
AndrewShf 4ffe0f1
merge with eisop master
AndrewShf fa1439e
merge code in valuevisitor
AndrewShf a15d727
change name of the enum
AndrewShf bfee453
remove daikon checkout id
AndrewShf 20d62af
add daikon checkout back, as it is resolved by another pr
AndrewShf 8e0f908
Merge remote-tracking branch 'eisop/master' into eisop_typecast
AndrewShf 91b22c9
Merge branch 'master' into eisop_typecast
AndrewShf 09cc33d
Merge branch 'master' into eisop_typecast
wmdietl 24105c4
Merge remote-tracking branch 'eisop/master' into eisop_typecast
AndrewShf c2bea34
Merge remote-tracking branch 'origin/eisop_typecast' into eisop_typecast
AndrewShf 1ec438e
add changelog entry
AndrewShf a6fb6ce
Merge branch 'master' into eisop_typecast
AndrewShf 724a95e
Merge branch 'master' into eisop_typecast
AndrewShf d241446
Merge branch 'master' into eisop_typecast
AndrewShf 07eaacb
Merge branch 'master' into eisop_typecast
wmdietl 4229827
Merge branch 'master' into eisop_typecast
wmdietl fc9ad98
Enum rename; Improve comments
AndrewShf d06ad1f
rename enum and improve comments in the test file CastFromTtoT.java
AndrewShf f4ffe07
improve jovadoc
AndrewShf ac60c2e
move isTypeCastSafe to an earlier position
AndrewShf 0115fbe
Merge remote-tracking branch 'eisop/master' into eisop_typecast
AndrewShf 67ba76b
use new apis for the change
AndrewShf 0b78587
fix error messages on the test files
AndrewShf 1b8f4ab
fix error messages on the test files
AndrewShf 2d969fc
Merge remote-tracking branch 'eisop/master' into eisop_typecast
AndrewShf 1b20546
improve document
AndrewShf b94311d
Merge branch 'master' into eisop_typecast
AndrewShf 98060e3
Merge branch 'master' into eisop_typecast
wmdietl f4d4ec1
Merge branch 'master' into eisop_typecast
wmdietl 0831233
Merge branch 'master' into eisop_typecast
wmdietl 9147d86
Merge branch 'master' into eisop_typecast
wmdietl 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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import org.checkerframework.checker.signedness.qual.*; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| class CastFromTtoT<T extends @UnknownSignedness Object> { | ||
| @SuppressWarnings("unchecked") | ||
| T bar(@UnknownSignedness Object p) { | ||
| // Seems to have no cast in terms of the qualifier (from @UnknownSignedness to | ||
| // @UnknownSignedness), but in instantiation, it could be a downcast. | ||
| // See method foo below. It's okay not to report downcast warnings as Javac will warn about | ||
| // casting object to 'T' (unchecked warning) | ||
| T x = (T) p; | ||
| return x; | ||
| } | ||
|
|
||
| void foo(CastFromTtoT<@Signed Integer> s, @UnknownSignedness Object local) { | ||
| // Here, we passed in an @UnknownSignedness object and the method signature after | ||
| // substitution is @Signed Integer bar(@UnknownSignedness Object). This makes the typecast | ||
| // discussed earlier a downcast. | ||
| @Signed Integer x = s.bar(local); | ||
| } | ||
|
|
||
| class Inner<T extends @UnknownSignedness Object> { | ||
| T bar2(@Signed T p) { | ||
| // The casting expression below looks like an upcast (in terms of the qualifier), | ||
| // but it could be a downcast in invocation (See method foo2 below for an example). | ||
| // We should report downcast warning if there is one because | ||
| // Javac doesn't warn when casting a variable from type T to T. | ||
| // :: warning: (cast.unsafe) | ||
| T x = (T) p; | ||
| return x; | ||
| } | ||
|
|
||
| void foo2(Inner<@SignednessGlb Integer> s, @Signed Integer local) { | ||
| // Here, we passed in an @Signed integer and the method signature after | ||
| // substitution is @SignednessGlb Integer bar2(@Signed Object). This makes the typecast | ||
| // discussed in method bar2 a downcast. | ||
| @SignednessGlb Integer x = s.bar2(local); | ||
| } | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.