Bug 120263 - [compiler] missing binding on array initializer
Summary: [compiler] missing binding on array initializer
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-11 06:08 EST by Martin Aeschlimann CLA
Modified: 2006-02-14 11:55 EST (History)
0 users

See Also:


Attachments
Regression test (2.71 KB, patch)
2005-12-14 11:52 EST, Olivier Thomann CLA
no flags Details | Diff

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