Bug 120263

Summary: [compiler] missing binding on array initializer
Product: [Eclipse Project] JDT Reporter: Martin Aeschlimann <martinae>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.2 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Regression test none

Description Martin Aeschlimann CLA 2005-12-11 06:08:05 EST
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() {
	}
}
Comment 1 Philipe Mulet CLA 2005-12-12 08:58:04 EST
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.
Comment 2 Martin Aeschlimann CLA 2005-12-12 10:00:30 EST
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...
Comment 3 Philipe Mulet CLA 2005-12-12 15:20:33 EST
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.
Comment 4 Olivier Thomann CLA 2005-12-14 11:52:28 EST
Created attachment 31748 [details]
Regression test
Comment 5 Philipe Mulet CLA 2005-12-17 08:33:24 EST
Fixed for build > M4.
Added ArrayTest#test009.
Added ASTConverter15Test#test0206.
Comment 6 Jerome Lanneluc CLA 2006-02-14 11:55:13 EST
Verified for 3.2 M5 using build I20060214-0010