| Summary: | [inline] Inline Constant and Inline Local Variable are missing parentheses for extended '-' chains | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Markus Keller <markus.kell.r> | ||||||
| Component: | UI | Assignee: | Markus Keller <markus.kell.r> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | CC: | daniel_megert, raksha.vasisht | ||||||
| Version: | 3.5 | Flags: | daniel_megert:
review+
|
||||||
| Target Milestone: | 3.5.1 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Windows XP | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
The bug is in ASTNodes.substituteMustBeParenthesized(Expression, Expression), where this shortcut is invalid:
if (locationInParent instanceof ChildListPropertyDescriptor) {
// e.g. argument lists of MethodInvocation, ClassInstanceCreation, ...
return false;
} else
Fix is to replace the test by:
if (locationInParent instanceof ChildListPropertyDescriptor
&& locationInParent != InfixExpression.EXTENDED_OPERANDS_PROPERTY) {
Created attachment 139321 [details]
Test
Released to HEAD. That's a nasty one, since the subtle error can be hard to spot (especially the off-by-1 case where I ran into this bug). Dani, do you agree for 3.5.1? Created attachment 139411 [details]
Fix
Patch is good and makes sense to fix in 3.5.1. Fixed in R3_5_maintenance branch. Verified for 3.6 M1 using I20090803-1800 Filed bug 285565 to track a special case with tab size = 0. Verified in M20090729-0903. |
I20090605-1444 Inline Constant and Inline Local Variable are missing parentheses for extended '-' chains: public class Try { public static final int B= 12; public static final int C= B - 1; //inline C public static final int K= 99; public static void main(String[] args) { // int B= 12; // int C= B - 1; //inline C // int K= 99; int f1= K - 1 - C; int f2= K - C - C - C; int x1= K + C; int x2= K - C; int x3= K + 1 - C; int x4= K - 1 + C; int x5= K + 1 + C - C - C; } }