Bug 133125 - [compiler][null] need to report the null status of expressions and analyze them simultaneously
Summary: [compiler][null] need to report the null status of expressions and analyze th...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC All
: P5 normal (vote)
Target Milestone: 3.7 M2   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 292478
Blocks:
  Show dependency tree
 
Reported: 2006-03-24 05:40 EST by Maxime Daniel CLA
Modified: 2010-09-14 05:37 EDT (History)
4 users (show)

See Also:


Attachments
proposed patch (4.09 KB, patch)
2010-07-17 12:00 EDT, Stephan Herrmann CLA
no flags Details | Diff
same fix with formatting and copyright (6.36 KB, patch)
2010-09-01 11:51 EDT, Ayushman Jain CLA
amj87.iitr: iplog+
amj87.iitr: review+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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