Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 401354

Summary: [clean up] "Remove unnecessary casts" breaks compilation
Product: [Eclipse Project] JDT Reporter: Jan Koehnlein <jan>
Component: UIAssignee: Noopur Gupta <noopur_gupta>
Status: CLOSED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 4.3   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X   
Whiteboard:

Description Jan Koehnlein CLA 2013-02-20 14:25:18 EST
In Xtext, we have the following lines in EcoreUtil2:

  @SuppressWarnings("unchecked")
  public static <T extends EObject> T clone(T eObject) {
    return (T) EcoreUtil.copy(eObject);
  }

Where EcoreUtil copy is from EMF and has the signature

  public static <T extends EObject> T copy(T eObject)

When saving our EcoreUtil2, the cast in the return statement is removed by the "Remove unnecessary casts" cleanup action. This results in a compile error on Hudson:

Error: file /opt/users/hudsonbuild/.hudson/jobs/xtext.gerrit/workspace/org.eclipse.xtext.git/plugins/org.eclipse.xtext/src/org/eclipse/xtext/EcoreUtil2.java, line 130: Type mismatch: cannot convert from EObject to T
Comment 1 Jan Koehnlein CLA 2013-02-20 14:25:55 EST
Tested with Eclipse 4.3M5a on MacOSX 64bit.
Comment 2 Dani Megert CLA 2013-02-21 03:50:56 EST
Noopur, please investigate.
Comment 3 Jan Koehnlein CLA 2013-02-21 05:25:13 EST
My fault. I am using a different target platform than Hudson, and EMF has generified the method in my version, so the cast was really obsolete here.