-
Notifications
You must be signed in to change notification settings - Fork 134
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
[Enhanced Switch][Null] Missing Null pointer access warning with total/unconditional patterns in case labels #3382
[Enhanced Switch][Null] Missing Null pointer access warning with total/unconditional patterns in case labels #3382
Conversation
srikanth-sankaran
commented
Dec 3, 2024
- Fixes [Enhanced Switch][Null] Missing Null pointer access warning with total/unconditional patterns #3381
Expecting some tests to fail org.eclipse.jdt.core.tests.compiler.regression.NullAnnotationTests21.test_totalTypePatternDoesNotAdmitNull() but these need to be studied to see if expectation is valid |
Looking at So when @stephan-herrmann - The proposed patch is still WIP, comments are welcome |
9821164
to
2ee0b1e
Compare
I think I have remastered the "failing" tests with right expectations. @stephan-herrmann thanks for your review. |
total/unconditional patterns in case labels * Fixes eclipse-jdt#3381
2ee0b1e
to
a753a21
Compare
looks like this changed between Java 18 and 19.
looking into it now. |
---------- | ||
1. ERROR in X.java (at line 6) | ||
switch (i) { | ||
^ | ||
Null pointer access: The variable i can only be null at this location | ||
---------- | ||
2. ERROR in X.java (at line 12) | ||
switch (i) { | ||
^ | ||
Null pointer access: This expression of type Integer is null but requires auto-unboxing | ||
---------- |
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.
@srikanth-sankaran do you have an idea why these are different error messages?
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.
@srikanth-sankaran do you have an idea why these are different error messages?
Yes, I had looked into this. In the former case its is a type switch which doesn't call for unboxing and in the latter switch on the unboxed integer. This results in a special message in the latter case.
total/unconditional patterns in case labels + code simplification Fixes eclipse-jdt#3381
@srikanth-sankaran your turn again :) |
Your additional changes look good, Thanks @stephan-herrmann! |
eclipse-jdt#3319 This was fixed by eclipse-jdt#3382
The first commit from here also fixes #3319 - basically the isNullHostile method's wrong result in the presence of total patterns was inhibiting a diagnostic from being reported. |