Bug 239203

Summary: [compiler][1.5] Different behaviour between Eclipse compiler and javac with generic methods
Product: [Eclipse Project] JDT Reporter: Mauro Molinari <mauromol>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.4   
Target Milestone: 3.5 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Mauro Molinari CLA 2008-07-02 04:50:59 EDT
Build ID: I20080617-2000

Steps To Reproduce:
1. Create three classes:

---
package a;
public class A<I extends B>
{
}
---
package a;
public class B
{
}
---
package a;

public class C
{
  public <I extends B, C extends A<I>> A<I> foo(Class<C> clazz)
	{
		A<I> ret = bar("bla");
		return ret;
	}
  
  public <I extends B, C extends A<I>> A<I> bar(String clazzName)
	{
		return null;
	}
}
---

2. Eclipse doesn't give any compilation error
3. if you try to compile class C with javac (I tried both 1.5.0_15 and 1.6.0_05) I get the following error:

src\a\C.java:7: incompatible types; inferred type argument(s) I,java.lang.Object
 do not conform to bounds of type variable(s) I,C
found   : <I,C>a.A<I>
required: a.A<I>
                A<I> ret = bar("bla");
                              ^

More information:
I know this code is silly and debatable (it has been changed after seeing this compilation error in javac! :-P), however Eclipse didn't help with that.
Comment 1 Kent Johnson CLA 2008-07-08 12:34:53 EDT
Not a regression from 3.3.x
Comment 2 Philipe Mulet CLA 2008-12-12 11:23:22 EST
I think this is a bug in javac that when using 15.12.2.8 to infer from expected type it shouldn't use Object, but upper bound (like we do).
If it did, then it would be able to compile this code correctly.

Comment 3 Philipe Mulet CLA 2008-12-12 11:44:47 EST
Closing as a javac bug.
Added GenericTypeTest#test1428
Comment 4 Frederic Fusier CLA 2009-01-27 07:11:03 EST
Verified for 3.5M5