Bug 74943 - Extract Local variable with increment operator has unintended consequences
Summary: Extract Local variable with increment operator has unintended consequences
Status: RESOLVED DUPLICATE of bug 27740
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-24 08:59 EDT by Andrew McCullough CLA
Modified: 2004-10-04 07:05 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 Andrew McCullough CLA 2004-09-24 08:59:05 EDT
Because the increment operator has what amounts to a side effect, the using 
extract local variable in a method with muiltiple getXX(i++) type lines of code 
gives an incorrect result.  For example this code: 

Object o1 = myList.get(index++);
Object o3 = myList.get(index++);
Object o4 = myList.get(index++);
Object o5 = myList.get(index++);

After extracting the first "myList.get(index++)", yields:

Object object = myList.get(index++);
Object o1 = object;
Object o3 = object;
Object o4 = object;
Object o5 = object;

which is clearly not what one wants.

-Andrew
Comment 1 Dirk Baeumer CLA 2004-10-04 07:05:19 EDT

*** This bug has been marked as a duplicate of 27740 ***