Bug 58978 - [1.5] Generic method needs better error reporting
Summary: [1.5] Generic method needs better error reporting
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-17 05:56 EDT by Stefan Matthias Aust CLA
Modified: 2005-01-11 11:02 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 Stefan Matthias Aust CLA 2004-04-17 05:56:53 EDT
The code shown below raises an error: "The method sort(List<T>) in the type
Collections is not applicable for the arguments (List<Test>)"  

It should raise an error like "The method sort(List<T extends Comparable<? super
T>>)..." to give an hint why the code doesn't work.  

I know that that method's signature is damn difficult to understand and the
important part is the generic type definition in front of the signature which is
unfortunately omitted right now.

 import java.util.Collections;
 import java.util.List;
 public class Test {
  List<Test> t;
  void t1() {
   Collections.sort(t);
  }
 }
Comment 1 Philipe Mulet CLA 2004-04-21 12:51:54 EDT
This is indeed planned. We have to introduce a specific message in case type 
inference issued a type which doesn't satisfy the bound check.
Comment 2 Philipe Mulet CLA 2004-04-28 19:10:16 EDT
Support added. You would now get the (long) message:

Bound mismatch: The generic method sort(List<T>) of type Collections is not 
applicable for the arguments (List<Test>) since the type Test is not a valid 
substitute for the bounded parameter <T extends Comparable<? super T>>

Fixed