Bug 77118 - [1.5] Covariance: cannot override method returning Object with method returning an interface
Summary: [1.5] Covariance: cannot override method returning Object with method returni...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-27 11:12 EDT by A Vaskys CLA
Modified: 2004-11-03 12:27 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 A Vaskys CLA 2004-10-27 11:12:12 EDT
The following classes compile using JDK 1.5.0 final:

public class Test {
   public Object getItem() {
      return null;
   }
}

public class GoodTest extends Test {
   public String getItem() {
      return null;
   }  
}

public class BadTest extends Test {
   public Comparable getItem() {
      return null;
   }
}

In Eclipse, however, BadTest gives the following compile error for getItem():
   The return type is incompatible with Test.getItem()

This seems to consistently happen when a method returning an Object is
overridden with a method returning an interface, even though it is valid java
1.5 code.

I am using Eclipse 3.1M2.
Comment 1 Kent Johnson CLA 2004-10-27 13:53:47 EDT
Fixed

Added test341().
Comment 2 David Audel CLA 2004-11-03 12:27:15 EST
Verified for 3.1M3 with build I20041102