Bug 258039 - [1.5][compiler] Misleading error message for "instanceof List<Object>"
Summary: [1.5][compiler] Misleading error message for "instanceof List<Object>"
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-12-09 05:02 EST by Jerome Lanneluc CLA
Modified: 2008-12-11 11:17 EST (History)
1 user (show)

See Also:


Attachments
Proposed patch (7.16 KB, patch)
2008-12-09 07:59 EST, Philipe Mulet CLA
no flags Details | Diff
Better patch (19.38 KB, patch)
2008-12-09 09:21 EST, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2008-12-09 05:02:01 EST
I20081209-0100

import java.util.List;
public class X {
  boolean foo() {
    return null instanceof List<Object>; 
  }
}

This reports: "Cannot perform instanceof check against parameterized type List<Object>. Use instead its raw form List since generic type information will be erased at runtime"

It should not suggests to us a raw type since it will trigger a warning (see bug 252120). It should suggests to use List<?> instead.
Comment 1 Philipe Mulet CLA 2008-12-09 07:29:48 EST
True, but note that quickfix caused a compile error to be raised, which is bad when attempting to fix a warning... they should het a bug opened as well.
Comment 2 Jerome Lanneluc CLA 2008-12-09 07:38:41 EST
(In reply to comment #1)
> True, but note that quickfix caused a compile error to be raised, which is bad
> when attempting to fix a warning... they should het a bug opened as well.
Entered bug 258059 against JDT/UI
Comment 3 Philipe Mulet CLA 2008-12-09 07:55:55 EST
Note also, that our message wasn't good for instanceof T (type param). 

e.g.
import java.util.*;
public class X {
	<T extends List<Object>> boolean foo2() {
		return null instanceof T;
	}
}

--> Cannot perform instanceof check against type parameter T. Use instead its erasure List<E> since generic type information will be erased at runtime

Will fix it as well.
Comment 4 Philipe Mulet CLA 2008-12-09 07:57:44 EST
Added GenericTypeTest#test1426
Comment 5 Philipe Mulet CLA 2008-12-09 07:59:07 EST
Created attachment 119898 [details]
Proposed patch
Comment 6 Philipe Mulet CLA 2008-12-09 09:21:39 EST
Created attachment 119906 [details]
Better patch
Comment 7 Philipe Mulet CLA 2008-12-10 12:43:28 EST
Released for 3.5M4
Comment 8 Philipe Mulet CLA 2008-12-10 12:44:23 EST
Fixed
Comment 9 Jerome Lanneluc CLA 2008-12-11 11:17:54 EST
Verified for 3.5M4 using I20081211-0100