Bug 77118

Summary: [1.5] Covariance: cannot override method returning Object with method returning an interface
Product: [Eclipse Project] JDT Reporter: A Vaskys <andrius.vaskys>
Component: CoreAssignee: Kent Johnson <kent_johnson>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M3   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

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