Bug 98331

Summary: [1.5][compiler] Casting Conversion needs to check all supertypes for conflicts
Product: [Eclipse Project] JDT Reporter: Tim Hanson <thanson>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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.