Community
Participate
Working Groups
See NullReferenceTest #34. In the following code, the null status of the expression is computed too early and yields unknown instead of potentially null. Object o = b ? null : new Object(); o.toString(); // should complain A possible solution would be to compute the null status just in time so as to be able to transfer it to o as it really is.
Post 3.2.
Reopening as P5 (since RESOLVED LATER is deprecated).
*** Bug 195757 has been marked as a duplicate of this bug. ***
Created attachment 174560 [details] proposed patch This patch leverages new infrastructure from bug 292478 to improve in this situation: ConditionalExpression now propagates whether either branch is (potentially) null. More sophisticated analysis is still not possible as witnessed by two new disabled tests: expressions like (o == null) ? new X(): o cannot detect that null is not possible, because analysis of the condition is not taken into account here.
Could you "copy" the if analysis (condition, then branches), to the ternary operator ?
The above patch looks good. Lets tackle the issue of analysis of the condition in nullStatus(...) in bug 324178
Created attachment 177976 [details] same fix with formatting and copyright corrected some formatting (space after // in line comments), and added copyright
Released in HEAD for 3.7M2
Reopening since bug 324762 happens occurs because of this.
This was happening because of a deficiency in the fix for bug 292478. With the new fix for bug 292478, this has been resolved. So closing.
Verified for 3.7 M2 using build I20100909-1700