Bug 129504 convert to enhanced for loop breaks on wildcards
3.2M5 public class A { void f(List<? extends Number> x){ for (Iterator<? extends Number> iter = x.iterator(); iter.hasNext();) { Number num = iter.next(); //do stuff }} } This gets converted to something that does not compile. Expected: void f(List<? extends Number> x){ for (Number number:x){ Number num = number; //do stuff }} cleanup has the same problem
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/ConvertIterableLoopQuickFixTest.java
"		}\r\n" + 
				"	}\r\n" + 
				"}");
		String expected= buf.toString();
		assertEqualString(preview, expected);
	}
	public void testMethodCall2() throws Exception {
		IPackageFragment pack= fSourceFolder.createPackageFragment("test", false, null);
		StringBuffer buf= new StringBuffer();
		buf.append("package test;\r\n" + 
				"import java.util.Collection;\r\n" + 
				"import java.util.Iterator;\r\n" + 
				"public class A {\r\n" + 
				"	Collection<String> c;\r\n" + 
				"	private Collection<String> getCollection() {\r\n" + 
				"		return c;\r\n" + 
				"	}\r\n" + 
				"	public A() {\r\n" + 
				"		for (final Iterator<String> iterator= this.getCollection().iterator(); iterator.hasNext();) {\r\n" + 
				"			String test= iterator.next();\r\n" + 
				"			String backup= test;\r\n" + 
				"			System.out.println(backup);\r\n" + 
				"		}\r\n" + 
				"	}\r\n" + 
				"}");
		ICompilationUnit unit= pack.createCompilationUnit("A.java", buf.toString(), false, null);
		List proposals= fetchConvertingProposal(buf, unit);
		assertNotNull(fConvertLoopProposal);
		assertCorrectLabels(proposals);
		String preview= getPreviewContent(fConvertLoopProposal);