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

Bug 312474

Summary: [quick assist] Exchange left/right infix operands refactoring removes parens inappropriately
Product: [Eclipse Project] JDT Reporter: Oisín Mac Fhearaí <denpashogai>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.5.2   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

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 ***