Bug 84743

Summary: [1.5][compiler] Cast between two interfaces doesn't need to check compatibility of method return types
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Olivier Thomann CLA 2005-02-08 16:53:11 EST
In 1.5, the following code should compile:

interface I {
   int foo();
}
interface J {
   String foo();
}
 
public class X implements I {
   public int foo() {
 	return 0;
   }
   public static void main(String[] args) {
         I i = new X();
        J j = (J) i;
        System.out.println(j);
  }
}

It will throw a ClassCastException at runtime.

In 1.4, the code would have failed at compile time.
Comment 1 Olivier Thomann CLA 2005-02-08 16:53:56 EST
Same result with == and != operators.
Comment 2 Philipe Mulet CLA 2005-02-10 09:12:58 EST
Added GenericTypeTest#test498. Also tuned CastTest to add nuance based on
compliance level.

Fixed
Comment 3 David Audel CLA 2005-02-16 09:01:41 EST
Verified in I20050215-2300