Bug 162400

Summary: [1.5][compiler] Return type inference does not perform well in array initializer
Product: [Eclipse Project] JDT Reporter: Philipe Mulet <philippe_mulet>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: dominik.stadler
Version: 3.3   
Target Milestone: 3.2.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

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