Bug 162400 - [1.5][compiler] Return type inference does not perform well in array initializer
Summary: [1.5][compiler] Return type inference does not perform well in array initializer
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 159987 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-10-26 09:36 EDT by Philipe Mulet CLA
Modified: 2008-09-16 09:40 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch (2.04 KB, patch)
2006-10-26 09:46 EDT, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2006-10-26 09:36:07 EDT
Build 3.3M2

The following code should compile clean:
public class X {
	static <T> T foo() {
		return null;
	}
	public static void main(String[] args) {
		String[] s = { foo() };
	}	
}

Currently, we do not set expected type for array initializer, and thus cannot conduct proper inference on type expectation for generic invocation of #foo().
Comment 1 Philipe Mulet CLA 2006-10-26 09:39:35 EDT
Added GenericTypeTest#test1056
Comment 2 Philipe Mulet CLA 2006-10-26 09:46:47 EDT
Created attachment 52746 [details]
Proposed patch
Comment 3 Philipe Mulet CLA 2006-10-26 09:56:03 EDT
*** Bug 159987 has been marked as a duplicate of this bug. ***
Comment 4 Philipe Mulet CLA 2006-10-26 09:58:26 EDT
Released for 3.3M3 (HEAD)

Backporting to 3.2.2 since bug 159987 demonstrates code corruption if applying cleanup action.
Comment 5 Philipe Mulet CLA 2006-10-27 12:02:19 EDT
Released for 3.2.2
Comment 6 David Audel CLA 2006-10-30 11:46:44 EST
Verified for 3.3 M3 using build I20061030-0010
Comment 7 Eric Jodet CLA 2007-01-15 07:34:58 EST
verified for 3.2.2 using build M20070112-1200