Bug 98331 - [1.5][compiler] Casting Conversion needs to check all supertypes for conflicts
Summary: [1.5][compiler] Casting Conversion needs to check all supertypes for conflicts
Status: CLOSED 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 RC2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-03 13:37 EDT by Tim Hanson CLA
Modified: 2005-06-10 13:31 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Hanson CLA 2005-06-03 13:37:22 EDT
Eclipse allows the following illegal cast:

interface C extends B<String>{}
interface D extends B<Integer>{}

interface A<T> {}
interface B<T> {}

class Z {
             public static void main(String[] args) {
                         D d = null;
                         C c = (C)d; // illegal
             }
}
Comment 1 Olivier Thomann CLA 2005-06-07 10:26:18 EDT
Reproduced with latest.
Comment 2 Philipe Mulet CLA 2005-06-10 03:31:58 EDT
Added GenericTypeTest#test732-736.

Cast check between interfaces must ensure no incompatible supertype exist. Check
similar to connecting superinterfaces for a type (except for hierarchy it is a
bit as no wildcard can be used).

Defined and used ReferenceBinding#hasIncompatibleSuperType(...)

Fixed
Comment 3 Philipe Mulet CLA 2005-06-10 06:51:40 EDT
Fixed
Comment 4 Philipe Mulet CLA 2005-06-10 09:33:36 EDT
Added more tests to cover mixed class/interface scenarii:
GenericTypeTest#test738-741
Comment 5 David Audel CLA 2005-06-10 12:28:06 EDT
Verified for 3.1 RC2 using build I20050610-0010 + JDT/Core head
Comment 6 Olivier Thomann CLA 2005-06-10 13:31:18 EDT
Verified in I20050610-1200.