Bug 104695 - [1.5][compiler] Compiler allows instanceof with non-reifiable array type
Summary: [1.5][compiler] Compiler allows instanceof with non-reifiable array type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.1   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-07-21 13:40 EDT by Markus Keller CLA
Modified: 2005-09-26 11:52 EDT (History)
0 users

See Also:


Attachments
Proposed fix (1.55 KB, patch)
2005-08-19 10:23 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 2005-07-21 13:40:59 EDT
N20050721-0010

class Bug<E> {
    void method(Object o) {
        if (o instanceof E[]) { //incorrect: cannot test non-reifiable type
            E[] es= (E[]) o;
        }
        if (o instanceof List<E>[]) { //incorrect too
            List<E>[] es= (List<E>[]) o; 
        }
    }
}
Comment 1 Olivier Thomann CLA 2005-08-19 10:23:49 EDT
Created attachment 26297 [details]
Proposed fix

This patch is passing all existing generic type tests.
Comment 2 Philipe Mulet CLA 2005-09-05 10:32:20 EDT
Fix is rather to improve TypeBinding#isReifiable() and to also use it in
instanceof expression.
Comment 3 Philipe Mulet CLA 2005-09-05 10:44:37 EDT
Also, the second assignment (to List<E>[] es) should issue an unchecked cast
warning.

Added GenericTypeTest#test814
Comment 4 Philipe Mulet CLA 2005-09-05 12:27:50 EDT
Addressed unchecked warning as well.
Also added GenericTypeTest#test815-817
Comment 5 Philipe Mulet CLA 2005-09-05 12:28:59 EDT
Fixed
Comment 6 David Audel CLA 2005-09-21 10:02:48 EDT
Verified in I20050920-0010 for 3.2M2
Comment 7 David Audel CLA 2005-09-26 11:52:25 EDT
Verified using M20050923-1430 for 3.1.1