forked from typetools/checker-framework
-
Notifications
You must be signed in to change notification settings - Fork 29
Handle intersection type in viewpoint adaptation #1434
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
Open
aosen-xiong
wants to merge
16
commits into
eisop:master
Choose a base branch
from
aosen-xiong:eisop-433
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.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e77c3c7
Fixes eisop#433
aosen-xiong faa762e
Remove typetool link
aosen-xiong 61bad4f
Don't create top
aosen-xiong e6ed628
Add warning
aosen-xiong 5aac11f
Also fix for recursive bound
aosen-xiong 54215a0
Merge branch 'master' into eisop-433
aosen-xiong 3a53122
Merge branch 'master' into eisop-433
wmdietl cbdb973
Merge branch 'master' into eisop-433
aosen-xiong b9aef56
Avoid mutating intersection bounds during adaptation
aosen-xiong 85fd8cf
Address intersection viewpoint adaptation reviews
aosen-xiong a1b4841
Clarify intersection annotation recomputation
aosen-xiong f8134de
Merge branch 'master' into eisop-433
wmdietl c7758c3
Update framework/src/main/java/org/checkerframework/framework/type/Ab…
aosen-xiong db4dfb9
Merge branch 'master' into eisop-433
aosen-xiong 0611ca6
Test viewpoint adaptation of intersection bounds
aosen-xiong 4d7087d
Fix viewpoint intersection test formatting
aosen-xiong 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Test case for EISOP Issue 433: | ||
| // https://github.com/eisop/checker-framework/issues/433 | ||
|
|
||
| public class IntersectionTypeNoCrash { | ||
|
|
||
| interface Foo {} | ||
|
|
||
| interface Bar {} | ||
|
|
||
| class Baz implements Foo, Bar {} | ||
|
|
||
| <T extends Foo & Bar> void call(T p) {} | ||
|
|
||
| void test() { | ||
| call(new Baz()); | ||
| } | ||
|
|
||
| void testCast(Object obj) { | ||
| Foo fooAndBar = (Foo & Bar) obj; | ||
| } | ||
| } |
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,86 @@ | ||
| // Test case for EISOP Issue 433: | ||
| // https://github.com/eisop/checker-framework/issues/433 | ||
|
|
||
| import viewpointtest.quals.*; | ||
|
|
||
| public class IntersectionTypes { | ||
|
|
||
| interface Foo {} | ||
|
|
||
| interface Bar {} | ||
|
|
||
| interface Accessor { | ||
| @ReceiverDependentQual Object get(); | ||
|
|
||
| void set(@ReceiverDependentQual Object o); | ||
| } | ||
|
|
||
| class Baz implements Foo, Bar, Accessor { | ||
| @Override | ||
| public @ReceiverDependentQual Object get() { | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| public void set(@ReceiverDependentQual Object o) {} | ||
| } | ||
|
|
||
| <T extends Foo & Bar> void call(T p) {} | ||
|
|
||
| <T extends Foo & Accessor> void callAccessor(T p) {} | ||
|
|
||
| class ViewpointAdaptedIntersectionBound<T extends @ReceiverDependentQual Accessor & Foo> { | ||
| void viewpointAdaptedIntersectionBound(@A T p, @A Object aObj, @B Object bObj) { | ||
| @A Object adapted = p.get(); | ||
| // :: error: (assignment.type.incompatible) | ||
| @B Object notAdaptedToB = p.get(); | ||
|
|
||
| p.set(aObj); | ||
| // :: error: (argument.type.incompatible) | ||
| p.set(bObj); | ||
| } | ||
| } | ||
|
|
||
| void foo(@A Object aObj, @B Object bObj) { | ||
| // :: warning: (cast.unsafe.constructor.invocation) | ||
| Baz baz = new @A Baz(); | ||
| call(baz); | ||
| callAccessor(baz); | ||
|
|
||
| @A Object adapted = baz.get(); | ||
| // :: error: (assignment.type.incompatible) | ||
| @B Object notAdaptedToB = baz.get(); | ||
|
|
||
| baz.set(aObj); | ||
| // :: error: (argument.type.incompatible) | ||
| baz.set(bObj); | ||
| } | ||
|
|
||
| void intersectionCasts(Object obj) { | ||
| Foo fooAndBar = (Foo & Bar) obj; | ||
| Accessor fooAndAccessor = (Foo & Accessor) obj; | ||
| } | ||
|
|
||
| void annotatedIntersectionCast(@B Object obj) { | ||
| // :: warning: (cast.unsafe) | ||
| Accessor fooAndAccessor = (@A Foo & Accessor) obj; | ||
| } | ||
|
|
||
| interface BType<X> {} | ||
|
|
||
| interface CType<X> {} | ||
|
|
||
| abstract class D<X extends BType<X> & CType<X>> {} | ||
|
|
||
| class BC implements BType<BC>, CType<BC> {} | ||
|
|
||
| class E extends D<BC> {} | ||
|
|
||
| <T extends BType<T> & CType<T>> void callBC(T p) {} | ||
|
|
||
| // Documents the current decision for https://github.com/eisop/checker-framework/issues/1735: | ||
| // when multiple bounds in an intersection type have explicit qualifiers in the same hierarchy, | ||
| // the later qualifier is ignored. | ||
| // :: warning: (explicit.annotation.ignored) | ||
| <T extends @A Foo & @B Bar> void callAnnotatedBounds(T p) {} | ||
| } |
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.