Bug 332268 - [assist] Allow proposals for static fields in initializers of fields being declared textually in advance
Summary: [assist] Allow proposals for static fields in initializers of fields being de...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.7 M5   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-10 00:45 EST by Ayushman Jain CLA
Modified: 2011-01-25 03:34 EST (History)
1 user (show)

See Also:
srikanth_sankaran: review+


Attachments
proposed fix extended (5.66 KB, patch)
2010-12-23 09:28 EST, Ayushman Jain CLA
no flags Details | Diff

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