Community
Participate
Working Groups
20051211 In the following example, the array initalizer could have a binding. Quick fix would like to use the binding to suggest the correct type for the created attribute. package pack; public class E { public @interface Annot { } @Annot(newAttrib= {1, 2}) public void foo() { } }
Type can be inferred, based on first initializer element type (this is what we use for error reporting). Also will make resolution more resilient, and ensure dispatching resolution into all initializer expressions.
In JDT.UI we have the problem that we can't create a binding, e.g. creating int[] if we have int. If we get that then I could also fo the infering myself...
My fix is doing both inference and propagation through elements. Note that inference isn't very smart, simply wrappering the first element type into an array. It could be improved using lub algorithm, but this feels overkill.
Created attachment 31748 [details] Regression test
Fixed for build > M4. Added ArrayTest#test009. Added ASTConverter15Test#test0206.
Verified for 3.2 M5 using build I20060214-0010