Bug 258059

Summary: [quick fix] Quick fix suggests invalid List<Object> for "instanceof List"
Product: [Eclipse Project] JDT Reporter: Jerome Lanneluc <jerome_lanneluc>
Component: UIAssignee: Markus Keller <markus.kell.r>
Status: RESOLVED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: daniel_megert, markus.kell.r
Version: 3.4   
Target Milestone: 3.5 M5   
Hardware: All   
OS: All   
Whiteboard:

Description Jerome Lanneluc CLA 2008-12-09 07:37:52 EST
I20081209-0100

1. Paste the following in Package Explorer
import java.util.List;
public class X {
  boolean foo() {
    return null instanceof List; 
  }
}
2. You should get a warning: "List is a raw type. References to generic type List<E> should be parameterized"
3. Bring up Quick Fix and choose "Add type arguments to 'List'"
4. You have to choices: 
  - inserting '<?>' (valid suggestion)
  - inserting '<Object>' (invalid suggestion)

If you choose the second suggestion, the resulting code has the following error:
"Cannot perform instanceof check against parameterized type List<Object>. Use instead its raw form List since generic type information will be erased at runtime"
Comment 1 Jerome Lanneluc CLA 2008-12-09 09:01:46 EST
(In reply to comment #0)
> 4. You have to choices: 
Should read: "You have two choices:"
Comment 2 Markus Keller CLA 2008-12-11 11:40:25 EST
Fixed in HEAD.