Bug 258059 - [quick fix] Quick fix suggests invalid List<Object> for "instanceof List"
Summary: [quick fix] Quick fix suggests invalid List<Object> for "instanceof List"
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 minor (vote)
Target Milestone: 3.5 M5   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-09 07:37 EST by Jerome Lanneluc CLA
Modified: 2008-12-11 11:41 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.