Bug 94648

Summary: [1.5][compiler] Compiler don't see that my class implements Comparable (only M6)
Product: [Eclipse Project] JDT Reporter: Giannandrea Castaldi <g.castaldi>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: major    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M7   
Hardware: PC   
OS: All   
Whiteboard:

Description Giannandrea Castaldi CLA 2005-05-11 06:24:44 EDT
Hi,
using eclipse 3.1 M6 the compiler gives an error if I try to call the method
java.util.Collections.sort(List<T>) with a list that contains objects of a type
that implements Comparable. It seems that the compiler don't recognize that my
type implements Comparable.
The error message is the following: "Bound mismatch: The generic method
sort(List<T>) of type Collections is not applicable for the arguments
(List<MyClass>) since the type MyClass is not a valid substitute for the bounded
parameter <T extends Comparable<? super T>>". The problem there is both on
windows and linux.
With eclipe M4 there is no problem. Here below there is an example with point
out where there is the error.

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class MyClass implements Comparable {
	public int compareTo(Object o) {
		return 0;
	}

	public static void main(String[] args) {
		List<MyClass> myList = new ArrayList<MyClass>();
		Collections.sort(myList); <-- Here is the error
	}
}

Thanks.

Giannandrea
Comment 1 Philipe Mulet CLA 2005-05-12 06:12:16 EDT
This was resolved a while ago, try a more recent I-build.

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