Skip to content
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

Merged
merged 12 commits into from
Nov 21, 2023
Merged

Improve initialization type frames #621

merged 12 commits into from
Nov 21, 2023

Conversation

flo2702
Copy link
Collaborator

@flo2702 flo2702 commented Nov 20, 2023

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.

@wmdietl wmdietl changed the title Fix #610 Improve initialization type frames Nov 21, 2023
Copy link
Member

@wmdietl wmdietl left a 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.

public @Nullable Object f;

public TypeFrames5(boolean dummy) {
@UnderInitialization(TypeFrames5.class) TypeFrames5 a = this;
Copy link
Member

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
Copy link
Member

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?

Copy link
Member

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

Copy link
Member

@wmdietl wmdietl left a 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!

@wmdietl wmdietl enabled auto-merge (squash) November 21, 2023 16:57
@wmdietl wmdietl merged commit 4f5600e into eisop:master Nov 21, 2023
41 of 42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@MonotonicNonNull fields now prevent final-class constructors from calling a method at the end
3 participants