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

Model the enclosing expression node for ObjectCreationNode and type check the enclosing expression for inner classes #405

Merged
merged 21 commits into from
Feb 23, 2023

Conversation

al3xliu
Copy link
Collaborator

@al3xliu al3xliu commented Feb 19, 2023

Fixes #282 .

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.

Thank you for all the improvements to this!

class InnerWithExplicitEnclosingExpression1 {
InnerWithExplicitEnclosingExpression1(
@UnknownInitialization NullnessEnclosingExprTest NullnessEnclosingExprTest.this) {
// This will NOT lead to a NPE as we annotate @UnknownInitialization to the enclosing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should not lead to an NPE, because the dereference should be forbidden! Do you not get an error from the Nullness Checker on the dereference of f? If not, this is a problem!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I cannot get an error on this behavior, do you think we need to fix it in this pr?

al3xliu and others added 12 commits February 20, 2023 19:02
…aseTypeVisitor.java

Co-authored-by: Werner Dietl <wdietl@gmail.com>
…aseTypeVisitor.java

Co-authored-by: Werner Dietl <wdietl@gmail.com>
…aseTypeVisitor.java

Co-authored-by: Werner Dietl <wdietl@gmail.com>
…aseTypeVisitor.java

Co-authored-by: Werner Dietl <wdietl@gmail.com>
…liasingTransfer.java

Co-authored-by: Werner Dietl <wdietl@gmail.com>
…aseTypeVisitor.java

Co-authored-by: Werner Dietl <wdietl@gmail.com>
…SourceChecker.java

Co-authored-by: Werner Dietl <wdietl@gmail.com>
…NullnessEnclosingExprTest.java

Co-authored-by: Werner Dietl <wdietl@gmail.com>
@al3xliu al3xliu requested a review from wmdietl February 21, 2023 01:21
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 quick fixes! A few more comments.

if (enclosingExpr != null) {
scan(enclosingExpr, p);
enclosingExprNode = scan(enclosingExpr, p);
} else if (enclosingClassType.getKind() == TypeKind.DECLARED) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What other options are there? Maybe variable enclosingClassType shouldn't contain Class if it's not guaranteed to be a class?

Copy link
Collaborator Author

@al3xliu al3xliu Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The TypeKind of a static enclosing type is Typekind.None, so we need this condition. I change the name in my local.

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! Small comments I'll merge and then I'll merge once tests pass.

@wmdietl wmdietl merged commit 3e41fa5 into eisop:master Feb 23, 2023
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.

ObjectCreationNode does not model receiver expression in object creations
2 participants