Lines 77-85
Link Here
|
77 |
currentScope.problemReporter().uninitializedLocalVariable(localBinding, this); |
77 |
currentScope.problemReporter().uninitializedLocalVariable(localBinding, this); |
78 |
// we could improve error msg here telling "cannot use compound assignment on final local variable" |
78 |
// we could improve error msg here telling "cannot use compound assignment on final local variable" |
79 |
} |
79 |
} |
80 |
if (isReachable) { |
80 |
if (localBinding.useFlag == LocalVariableBinding.UNUSED) { |
81 |
localBinding.useFlag = LocalVariableBinding.USED; |
|
|
82 |
} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) { |
83 |
localBinding.useFlag = LocalVariableBinding.FAKE_USED; |
81 |
localBinding.useFlag = LocalVariableBinding.FAKE_USED; |
84 |
} |
82 |
} |
85 |
} |
83 |
} |
Lines 461-466
Link Here
|
461 |
* are optimized in one access: e.g "a = a + 1" optimized into "a++". |
459 |
* are optimized in one access: e.g "a = a + 1" optimized into "a++". |
462 |
*/ |
460 |
*/ |
463 |
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { |
461 |
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { |
|
|
462 |
if (!valueRequired && ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL)) { |
463 |
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; |
464 |
if (localBinding.useFlag == LocalVariableBinding.FAKE_USED) { |
465 |
// report the case of a local variable that is unread except for this compound assignment |
466 |
currentScope.problemReporter().unusedLocalVariable(localBinding.declaration); |
467 |
localBinding.useFlag = LocalVariableBinding.USED; // don't report again |
468 |
} |
469 |
} |
464 |
this.generateCompoundAssignment( |
470 |
this.generateCompoundAssignment( |
465 |
currentScope, |
471 |
currentScope, |
466 |
codeStream, |
472 |
codeStream, |
Lines 661-666
Link Here
|
661 |
return; |
667 |
return; |
662 |
case Binding.LOCAL : // assigning to a local variable |
668 |
case Binding.LOCAL : // assigning to a local variable |
663 |
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; |
669 |
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; |
|
|
670 |
|
671 |
if (!valueRequired) { |
672 |
if (localBinding.useFlag == LocalVariableBinding.FAKE_USED) { |
673 |
// report the case of a local variable that is unread except for postIncrement expressions |
674 |
currentScope.problemReporter().unusedLocalVariable(localBinding.declaration); |
675 |
localBinding.useFlag = LocalVariableBinding.USED; // don't report again |
676 |
} |
677 |
} |
678 |
|
664 |
// using incr bytecode if possible |
679 |
// using incr bytecode if possible |
665 |
if (localBinding.type == TypeBinding.INT) { |
680 |
if (localBinding.type == TypeBinding.INT) { |
666 |
if (valueRequired) { |
681 |
if (valueRequired) { |