Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 312474 - [quick assist] Exchange left/right infix operands refactoring removes parens inappropriately
Summary: [quick assist] Exchange left/right infix operands refactoring removes parens ...
Status: CLOSED DUPLICATE of bug 149801
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: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-11 13:37 EDT by Oisín Mac Fhearaí CLA
Modified: 2010-05-12 02:35 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oisín Mac Fhearaí CLA 2010-05-11 13:37:34 EDT
Build Identifier: 20100218-1602

Performing the "exchange left and right operands for infix expression" refactoring can strip parentheses around one operand, changing the meaning of the expression unexpectedly.

Marking as normal rather than minor because a user might trust that the refactoring preserves semantics, especially if they're unsure of the evaluation order/rules (I had to make a testcase to be sure).

		boolean a = true,b = true,c = false;
		boolean original = (a || b) && c;  // quick fix will allow the exchange to be performed if you position the cursor at the "&&"
		boolean swapped = c && a || b;  // producing this expression
		assertTrue(!original);  // ok
		assertEquals(original, swapped);  // fail

Reproducible: Always

Steps to Reproduce:
1. Paste the code above
2. (confirm that the refactoring produces the expression assigned to "swapped")
3. Run the test
Comment 1 Dani Megert CLA 2010-05-12 02:35:29 EDT

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