Bug 80736

Summary: [1.5] Compiler doesn't check that bounds have methods with same return type
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Olivier Thomann CLA 2004-12-10 17:16:55 EST
Eclipse compiler compiles that code without an error where it should report an
error because the method foo() exists for both bounds with a different return type.

interface I {
    String foo();
}

class A {
    public Object foo() {
      return null;
    }
}

public class X<T extends A&I> {
}

javac reports:
X.java:11: foo() in A cannot implement foo() in I; attempting to use
incompatible return type
found   : java.lang.Object
required: java.lang.String
Comment 1 Olivier Thomann CLA 2004-12-10 17:20:33 EST
Same problem when the two bounds are interfaces.

interface I {
    Float foo();
}

interface J {
    Integer foo();
}

public class X<T extends J&I> {
}

javac reports in this case:
X.java:9: types I and J are incompatible; both define foo(), but with unrelated
return types
public class X<T extends J&I> {

If you replace Integer with Object, it compiles fine.
Comment 2 Kent Johnson CLA 2005-01-13 13:29:00 EST
Added MethodVerify test032

NOTE: javac only reports these errors when the problem type follows the bounds

if the type X is defined first, then no errors are reported
Comment 3 David Audel CLA 2005-02-16 06:09:32 EST
Verified in I20050215-2300