Bug 62806

Summary: [1.5] Generic class not recognised as Generic
Product: [Eclipse Project] JDT Reporter: Roberto S. Tyley <Roberto.Eclipse>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: 3.1 M1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Roberto S. Tyley CLA 2004-05-18 17:04:48 EDT
With Eclipse I20040514 and Cheetah5 in a fresh install and a new project, I
created the following two parameterized classes- however in the second class
'Function' is incorrectly highlighted by Eclipse with the message "The type
Function is not generic; it cannot be parameterized with arguments <Y, X>":

----

public abstract class Function<Y,X> {
    
    public abstract Y eval(X x);

}

----

import java.util.*;

public class FunctionMappedComparator<Y,X> implements Comparator<X> {
	/*
	 * 'Function' is highlighted as an error here - the message is:
	 * "The type Function is not generic; it cannot be parameterized with arguments
<Y, X>"
	 */
    protected Function<Y,X> function;
    protected Comparator<Y> comparator;
    
    public FunctionMappedComparator(Function<Y,X> function,Comparator<Y>
comparator ) {
        this.function=function;
        this.comparator=comparator;
    }

    public int compare(X x1, X x2) {
        return comparator.compare(function.eval(x1),function.eval(x2));
    }

}

----

I'm using J2SE1.50 beta1 (1.5.0-beta-b32c) - yes, I'm one of those lusers who
has to wait for the public release of beta2! Does this reproduce with a current
drop of beta2?

Roberto
Comment 1 Philipe Mulet CLA 2004-05-21 15:50:26 EDT
Note: it doesn't make any difference whether you use beta1 or beta2, since you 
are actually using the Eclipse java compiler, not Sun javac. 

This being said, you aren't getting any compilation error when building; only 
errors in editor (i.e. no problem in problem view). This is due to the fact 
that our lightweight compilation mode used to compile on the fly as you type 
hasn't been leveraged for 1.5 support yet, and thus treats generic types as 
non generic ones (discarding the type parameters). It requires to upgrade the 
JavaModel implementation to properly handle errors in editor.
Comment 2 Philipe Mulet CLA 2004-05-21 15:51:59 EDT

*** This bug has been marked as a duplicate of 58722 ***