Bug 148957

Summary: [1.5][compiler] Inheritance with generic parameter poses problem if formulated differently
Product: [Eclipse Project] JDT Reporter: Volker Renneberg <volker.renneberg.external>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2   
Target Milestone: 3.3 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
SuperInterface
none
ProblemClass none

Description Volker Renneberg CLA 2006-06-28 05:09:10 EDT
Hi!

I do not know, whether this is an eclipse bug or not:

Assume, you have the following interface:

import java.util.Collection;
import javax.swing.JLabel;
public interface SuperInterface {
   public <A extends JLabel> void doIt(Collection<A> as);
}

and the following class, that inherits from the interface:

import java.util.Collection;
import javax.swing.JLabel;
public class ProblemClass implements SuperInterface {
   public void doIt(Collection<? extends JLabel> as) {
   }
}

Eclipse 3.2RC7 does not recognize the implementing method as an implementation. It says, there is a name clash.

ciao
Volker
Comment 1 Volker Renneberg CLA 2006-06-28 05:10:22 EDT
Created attachment 45450 [details]
SuperInterface

The given interface is in a package called "inheritance".
Comment 2 Volker Renneberg CLA 2006-06-28 05:11:15 EDT
Created attachment 45451 [details]
ProblemClass

The given interface is in a package called "inheritance".
Comment 3 Philipe Mulet CLA 2006-06-28 07:17:00 EDT
This is the intended behavior. Javac 1.6b88 agrees with us. Now I agree on the surface this is questionnable as a wildcard is usually considered to act as a type parameter when only referenced once...

To avoid the problem, define instead the following, which will be somewhat equivalent.

class ProblemClass implements SuperInterface {
   public <B extends JLabel> void doIt(Collection<B> as) {
   }
}

Added MethodVerifyTest#test095-096
Comment 4 Philipe Mulet CLA 2006-06-28 07:28:14 EDT
Actually, tests are MethodVerifyTest#test096-097