Bug 83218 - [1.5] Covariant return type & generics
Summary: [1.5] Covariant return type & generics
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 M5   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-01-19 13:31 EST by Bart Geraci CLA
Modified: 2005-02-16 07:24 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 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