Bug 307885 - Error message for instanceof <parameterized type> wrong arguments
Summary: Error message for instanceof <parameterized type> wrong arguments
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-01 10:59 EDT by Markus Keller CLA
Modified: 2010-04-27 06:30 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix + regression test (3.33 KB, patch)
2010-04-07 08:44 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2010-04-01 10:59:11 EDT
class Test<A> {
    interface MyInt<K> {
        K getKey();
    }
    class MyEntry implements MyInt<A> {
        public A getKey() { return null; }
        public boolean equals(Object o) {
            if(!(o instanceof MyEntry))
                return false;
            MyEntry m = (MyEntry) o;
            return m.getKey().equals(getKey());
        }
    }
}

The error message at "instanceof MyEntry" has its arguments swapped:

> "Cannot perform instanceof check against parameterized type Test<A>.MyEntry.
                                       should be "MyEntry" -> ^^^^^^^^^^^^^^^
> Use the form MyEntry instead since further generic type information will be
               ^^^^^^^ <- should be "Test<A>.MyEntry"
> erased at runtime".
Comment 1 Markus Keller CLA 2010-04-01 11:04:18 EDT
Oops, the arguments are not really swapped. The first argument is actually OK, but the second argument should be the erased type-qualified type, i.e.:
"Use the form Test.MyEntry instead ...".
Comment 2 Olivier Thomann CLA 2010-04-07 08:44:46 EDT
Created attachment 164036 [details]
Proposed fix + regression test
Comment 3 Olivier Thomann CLA 2010-04-07 08:45:56 EDT
Released for 3.6M7.
Regression test added in:
org.eclipse.jdt.core.tests.compiler.regression.GenericTypeTest#test1460
Comment 4 Jay Arthanareeswaran CLA 2010-04-27 06:30:55 EDT
Verified for 3.6M7 using build I20100424-2000.