-
Notifications
You must be signed in to change notification settings - Fork 19
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
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.
Thank you for all the improvements to this!
checker/src/test/java/org/checkerframework/checker/test/junit/NullnessEnclosingExprTest.java
Outdated
Show resolved
Hide resolved
checker/tests/nullness-enclosingexpr/NullnessEnclosingExprTest.java
Outdated
Show resolved
Hide resolved
class InnerWithExplicitEnclosingExpression1 { | ||
InnerWithExplicitEnclosingExpression1( | ||
@UnknownInitialization NullnessEnclosingExprTest NullnessEnclosingExprTest.this) { | ||
// This will NOT lead to a NPE as we annotate @UnknownInitialization to the enclosing |
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.
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!
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.
No, I cannot get an error on this behavior, do you think we need to fix it in this pr?
checker/tests/nullness-enclosingexpr/NullnessEnclosingExprTest.java
Outdated
Show resolved
Hide resolved
dataflow/src/main/java/org/checkerframework/dataflow/cfg/builder/CFGTranslationPhaseOne.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
Outdated
Show resolved
Hide resolved
framework/src/main/java/org/checkerframework/common/basetype/BaseTypeVisitor.java
Outdated
Show resolved
Hide resolved
…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>
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 quick fixes! A few more comments.
checker/tests/nullness-enclosingexpr/NullnessEnclosingExprTest.java
Outdated
Show resolved
Hide resolved
checker/tests/nullness-enclosingexpr/NullnessEnclosingExprTest.java
Outdated
Show resolved
Hide resolved
checker/tests/nullness-enclosingexpr/NullnessEnclosingExprTest.java
Outdated
Show resolved
Hide resolved
if (enclosingExpr != null) { | ||
scan(enclosingExpr, p); | ||
enclosingExprNode = scan(enclosingExpr, p); | ||
} else if (enclosingClassType.getKind() == TypeKind.DECLARED) { |
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.
What other options are there? Maybe variable enclosingClassType
shouldn't contain Class
if it's not guaranteed to be a class?
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! The TypeKind of a static enclosing type is Typekind.None, so we need this condition. I change the name in my local.
framework/src/main/java/org/checkerframework/framework/type/AnnotatedTypeFactory.java
Show resolved
Hide resolved
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! Small comments I'll merge and then I'll merge once tests pass.
Fixes #282 .