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

Bug 461487

Summary: Save Action "Remove Unecessary casts" also remove some casts necessary for overload resolution
Product: [Eclipse Project] JDT Reporter: Sebastien Arod <sebastien.arod>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED INVALID QA Contact:
Severity: critical    
Priority: P3 CC: stephan.herrmann
Version: 4.5   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Sebastien Arod CLA 2015-03-05 06:53:05 EST
Using the following snippet:


void handle(Object object) {
   if (object instanceof ClassA) {
     handle((String) object);
   } else if (object instanceof ClassB) {
     handle((ClassB) object);
   }
}

void handle(ClassA object) {
   ...
}

void handle(ClassB object) {
   ...
}

Remove unecessary cast removes the cast in the first method changing the behavior of the code...

This makes this feature highly dangerous to use.
Comment 1 Sebastien Arod CLA 2015-03-05 11:00:14 EST
In fact with the simple snippet I provided this works fine. I'll try to find a better case to reproduce.
Comment 2 Sebastien Arod CLA 2015-03-05 11:03:23 EST
Ok just forget it.
The problem occured between chair and keyboard...

My case were using several parameters and one of the method had the parameters in a different order...