Bug 133125

Summary: [compiler][null] need to report the null status of expressions and analyze them simultaneously
Product: [Eclipse Project] JDT Reporter: Maxime Daniel <maxime_daniel>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P5 CC: amj87.iitr, srikanth_sankaran, stephan.herrmann, utilisateur_182
Version: 3.2   
Target Milestone: 3.7 M2   
Hardware: PC   
OS: All   
Whiteboard:
Bug Depends on: 292478    
Bug Blocks:    
Attachments:
Description Flags
proposed patch
none
same fix with formatting and copyright amj87.iitr: iplog+, amj87.iitr: review+

Description Maxime Daniel CLA 2006-03-24 05:40:21 EST
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.
Comment 1 Maxime Daniel CLA 2006-04-25 00:47:51 EDT
Post 3.2.
Comment 2 Maxime Daniel CLA 2007-06-19 08:07:14 EDT
Reopening as P5 (since RESOLVED LATER is deprecated).
Comment 3 Maxime Daniel CLA 2007-07-09 02:50:04 EDT
*** Bug 195757 has been marked as a duplicate of this bug. ***
Comment 4 Stephan Herrmann CLA 2010-07-17 12:00:31 EDT
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.
Comment 5 utilisateur_768 CLA 2010-09-01 06:28:05 EDT
Could you "copy" the if analysis (condition, then branches), to the ternary operator ?
Comment 6 Ayushman Jain CLA 2010-09-01 07:23:34 EDT
The above patch looks good. Lets tackle the issue of analysis of the condition in nullStatus(...) in bug 324178
Comment 7 Ayushman Jain CLA 2010-09-01 11:51:48 EDT
Created attachment 177976 [details]
same fix with formatting and copyright

corrected some formatting (space after // in line comments), and added copyright
Comment 8 Ayushman Jain CLA 2010-09-01 11:52:45 EDT
Released in HEAD for 3.7M2
Comment 9 Ayushman Jain CLA 2010-09-08 12:24:31 EDT
Reopening since bug 324762 happens occurs because of this.
Comment 10 Ayushman Jain CLA 2010-09-09 13:48:08 EDT
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.
Comment 11 Srikanth Sankaran CLA 2010-09-14 05:37:00 EDT
Verified for 3.7 M2 using build I20100909-1700