-
Notifications
You must be signed in to change notification settings - Fork 428
Nullness Checker: Manually scan expression and reference type in visitInstanceOf (#7341) #7342
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
Nullness Checker: Manually scan expression and reference type in visitInstanceOf (#7341) #7342
Conversation
📝 WalkthroughWalkthroughThe pull request updates NullnessVisitor.visitInstanceOf to call Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
checker/src/main/java/org/checkerframework/checker/nullness/NullnessVisitor.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: typetools.checker-framework (misc_jdk25)
- GitHub Check: typetools.checker-framework (typecheck_part2_jdk25)
- GitHub Check: typetools.checker-framework (inference_part1_jdk25)
- GitHub Check: typetools.checker-framework (typecheck_part1_jdk25)
- GitHub Check: typetools.checker-framework (inference_part2_jdk25)
- GitHub Check: typetools.checker-framework (nonjunit_jdk25)
- GitHub Check: typetools.checker-framework (junit_jdk25)
🔇 Additional comments (1)
checker/src/main/java/org/checkerframework/checker/nullness/NullnessVisitor.java (1)
415-437: LGTM! The logic correctly addresses the issue.The implementation properly fixes issue #7341 by manually scanning the expression for nullness issues while avoiding the incorrect
instanceof.unsafewarning from the superclass. The control flow is sound:
super.scan(tree.getExpression(), p)ensures the expression is analyzed for nullness by dispatching to the appropriate visitor method- The reference type annotations are still checked (lines 423-433)
- Returning
nullwithout callingsuper.visitInstanceOf()prevents the incorrect warning
checker/src/main/java/org/checkerframework/checker/nullness/NullnessVisitor.java
Outdated
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
framework/tests/all-systems/Issue7341.java(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: typetools.checker-framework (typecheck_part2_jdk25)
- GitHub Check: typetools.checker-framework (nonjunit_jdk25)
- GitHub Check: typetools.checker-framework (inference_part1_jdk25)
- GitHub Check: typetools.checker-framework (junit_jdk25)
- GitHub Check: typetools.checker-framework (misc_jdk25)
- GitHub Check: typetools.checker-framework (typecheck_part1_jdk25)
- GitHub Check: typetools.checker-framework (inference_part2_jdk25)
smillst
left a comment
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!
Head branch was pushed to by a user without write access
2f1ab28 to
e816d13
Compare
No worries. Thanks for your reply and review! I noticed you enabled auto-merge yesterday, but the pipeline failed because it ran out of CPU resources on AWS. I’ve rerun the pipeline, and everything looks good to be merged now. @smillst |
|
@Gaoyan1999 Please do not force-push to GitHub. Force-pushing has no benefit, since we squash-and-merge pull requests. Force-pushing has negative consequences, such as removing code review comments on any deleted commits. Thanks again for your contribution. |
Thanks for the explanation! I didn’t realize force-pushing would remove review comments. I’ll avoid doing that in the future. Appreciate your patience! |
Summary
This PR addresses issue #7341 by modifying
visitInstanceOfin the NullnessVisitor.Problem
In the NullnessVisitor, the existing
visitInstanceOfonly checks the type part of theinstanceofexpression,but does not scan the expression itself. As a result, nullness issues in the expression could be missed.
Solution
super.visitInstanceOf()because, as noted in the existing comment,the superclass
BaseTypeVisitorwould also check the type and trigger incorrectinstanceof.unsafewarnings.super.scan(tree.getExpression(), p))in
NullnessVisitorto ensure proper nullness analysis without invoking the superclass logic.References