Bug 83218

Summary: [1.5] Covariant return type & generics
Product: [Eclipse Project] JDT Reporter: Bart Geraci <BJGeraci>
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 2000   
Whiteboard:

Description Bart Geraci CLA 2005-01-19 13:31:11 EST
Using Version: 3.1.0
Build id: I20050112-1200

Given the following code:
------------------------
interface Base<E> {
  public Base<E> proc();
}

abstract class Derived<D> implements Base<D> {

  abstract Derived<D> makeNew();
  
  public Derived<D> proc() {
  //     ******* "Derived" underlined.
  
    Derived<D> nu = makeNew();
    return nu;
  }
}
------------------------
Also, set the Java Compiler > Errors/Warnings > JDK 5.0 options > 
  "Unsafe type operation involving raw types" to "Error".

Eclipse returns this error: 

  Type safety: The return type Derived<D> of the method proc() of type
Derived<D> needs unchecked conversion to conform to the return type Base<E> of
inherited method

If the "Unsafe type operation..." is set to ignore, the error does not appear.
If the 2 classes are not parameterized, the error does not appear.
Comment 1 Olivier Thomann CLA 2005-01-21 12:03:38 EST
Compiles fine with HEAD contents.
Comment 2 Kent Johnson CLA 2005-02-04 16:17:17 EST
Added MethodVerify test040
Comment 3 David Audel CLA 2005-02-16 07:24:29 EST
Verified in I20050215-2300