-
Notifications
You must be signed in to change notification settings - Fork 347
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
Support unique classes (Fixes #3313) #3336
Changes from all commits
fd536c4
126014d
b2b91eb
1b756c0
4edfc68
dde03ef
22462e0
017082b
4b36609
fa03246
97ff12d
629a1a9
25b602a
91d8372
eb424fd
c324094
941cab0
d71f608
53a6c12
ff1b9e4
135b266
db149b9
e64f002
167d9cc
cf45fd6
f3d2479
9b60d82
1335ba2
1da4103
7b191e9
bd1fe05
37976e8
1523897
79f35f1
f6e67cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import org.checkerframework.common.aliasing.qual.Unique; | ||
|
||
@Unique class Data { | ||
@SuppressWarnings("unique.leaked") | ||
Data() {} // All objects of Data are now @Unique | ||
} | ||
|
||
class Demo { | ||
void check(Data p) { // p is @Unique Data Object | ||
// :: error: (unique.leaked) | ||
Data y = p; // @Unique p is leaked | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the type of the left-hand side important? Can you add another method that does
which I guess should also give a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ping. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, the type of the left-hand side isn't important. However, the method doesn't give an error, even when Data is explicitly annotated as @unique. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure how you mean this. Does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In the code given above, Object z = p; does raise an error. Hence, the left hand side isn't important. However, the check2 function (where you are returning a @unique Data as an Object) doesn't raise an error both in the typetools/master and in my modified code, even if the Data p is explicitly annotated as @unique Data p. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, can you expand this test case with the |
||
// :: error: (unique.leaked) | ||
Object z = p; // @Unique p is leaked | ||
} | ||
} |
This file was deleted.
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.
You should also update the javadoc with the change in behavior.
Do you understand what
canBeLeaked
expresses? The documentation is rather unclear.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.
I have changed the documentation for the canBeLeaked method in my latest commit