Bug 80736 - [1.5] Compiler doesn't check that bounds have methods with same return type
Summary: [1.5] Compiler doesn't check that bounds have methods with same return type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-12-10 17:16 EST by Olivier Thomann CLA
Modified: 2005-02-16 06:09 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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