Bug 258039

Summary: [1.5][compiler] Misleading error message for "instanceof List<Object>"
Product: [Eclipse Project] JDT Reporter: Jerome Lanneluc <jerome_lanneluc>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: philippe_mulet
Version: 3.4   
Target Milestone: 3.5 M4   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch
none
Better patch none

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