Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330415 - [inline] Refactor > Inline fails to parenthesize replaced arguments
Summary: [inline] Refactor > Inline fails to parenthesize replaced arguments
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.5.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Deepak Azad CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-16 19:07 EST by Missing name CLA
Modified: 2010-11-17 00:30 EST (History)
2 users (show)

See Also:


Attachments
This is a test case to demonstrate the bug (requires manual steps; see file). (741 bytes, text/x-java)
2010-11-16 19:08 EST, Missing name CLA
no flags Details
fix + tests (10.62 KB, patch)
2010-11-17 00:30 EST, Deepak Azad CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Missing name CLA 2010-11-16 19:07:25 EST
Build Identifier: M20100211-1343

Inlining a subtracted expression produces the wrong result because the refactoring tool fails to parenthesize the arguments.

Example: instead of x - (y + z), you can end up with x - y + z.

(See attached test case).

Reproducible: Always

Steps to Reproduce:
1. Run the test case as-is.
2. Inline each of the functions in main().
3. Run the test case again and observe the difference.
Comment 1 Missing name CLA 2010-11-16 19:08:49 EST
Created attachment 183272 [details]
This is a test case to demonstrate the bug (requires manual steps; see file).
Comment 2 Remy Suen CLA 2010-11-16 19:25:26 EST
Issues with Eclipse's Java tooling goes to JDT.
Comment 3 Deepak Azad CLA 2010-11-17 00:30:14 EST
Created attachment 183275 [details]
fix + tests

It is better to add extra parenthesis in some cases e.g. x + (y + z) , than change the semantics on inlining.
Comment 4 Deepak Azad CLA 2010-11-17 00:30:47 EST
Fixed in HEAD.