-
Notifications
You must be signed in to change notification settings - Fork 18
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
Improve initialization type frames #621
Conversation
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.
Thanks for this fix, in particular all the documentation improvements!
I have a few small questions.
I've added a further test and renamed the PR, see whether you like these changes.
checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java
Outdated
Show resolved
Hide resolved
checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java
Outdated
Show resolved
Hide resolved
checker/src/main/java/org/checkerframework/checker/initialization/InitializationVisitor.java
Show resolved
Hide resolved
...ain/java/org/checkerframework/checker/initialization/InitializationAnnotatedTypeFactory.java
Outdated
Show resolved
Hide resolved
public @Nullable Object f; | ||
|
||
public TypeFrames5(boolean dummy) { | ||
@UnderInitialization(TypeFrames5.class) TypeFrames5 a = this; |
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 added this test to show that the type of this
is correct even for non-final classes, which was previously also broken.
Can you think of another case to test?
for (VariableTree f : uninitializedFields) { | ||
fieldsString.add(f.getName()); | ||
} | ||
// TODO: improve the error message by showing the uninitialized fields |
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.
@Ao-senXiong Can you please open an issue for this TODO and see how to improve this error message?
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.
@Ao-senXiong Can you please open an issue for this TODO and see how to improve this error message?
Ok, I will open up an issue
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.
Thanks for the further improvements!
Fixes #610
An object of final class type
A
is now correctly considered@Initialized
when all non-monotonic, non-null fields have been assigned. Previously, it was only considered@UnderInitialization(A.class)
.The problem only occurred if some fields of the class were either monotonic or nullable, which was not previously covered by test cases.