Bug 332268

Summary: [assist] Allow proposals for static fields in initializers of fields being declared textually in advance
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: srikanth_sankaran
Version: 3.7Flags: srikanth_sankaran: review+
Target Milestone: 3.7 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
proposed fix extended none

Description Ayushman Jain CLA 2010-12-10 00:45:36 EST
With fix for bug 310427, we no longer allow the proposals for fields that have not yet been declared inside the initializer of a field being currently declared. But acc. to JLS 8.3.2.2

"Initialization expressions for instance variables may use the simple name of any static variable declared in or inherited by the class, even one whose declaration occurs textually later.
Thus the example:
class Test {
float f = j;
static int j = 1;
}
compiles without error; it initializes j to 1 when class Test is initialized, and initializes f to the current value of j every time an instance of class Test is created "

So content assist should not hide 'j' in the above case.
Comment 1 Ayushman Jain CLA 2010-12-10 01:53:09 EST
(In reply to comment #0)
> With fix for bug 310427, we no longer allow the proposals for fields that have
> not yet been declared inside the initializer of a field being currently
> declared. But acc. to JLS 8.3.2.2
> 
> "Initialization expressions for instance variables may use the simple name of
> any static variable declared in or inherited by the class, even one whose
> declaration occurs textually later.
> Thus the example:
> class Test {
> float f = j;
> static int j = 1;
> }
> compiles without error; it initializes j to 1 when class Test is initialized,
> and initializes f to the current value of j every time an instance of class
> Test is created "
> 
> So content assist should not hide 'j' in the above case.

Note that this is only true when the field being currently initialized is not itself static .
Comment 2 Ayushman Jain CLA 2010-12-23 09:28:45 EST
Created attachment 185770 [details]
proposed fix extended

Srikanth, can you please do a quick review? Thanks!
Comment 3 Srikanth Sankaran CLA 2010-12-23 18:06:28 EST
Looks good.
Comment 4 Ayushman Jain CLA 2011-01-06 08:23:37 EST
Released in HEAD for 3.7M5
Comment 5 Srikanth Sankaran CLA 2011-01-25 03:34:29 EST
Verified for 3.7 M5 using build id: I20110124-1800