Lines 77-86
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.USED) { |
81 |
localBinding.useFlag = LocalVariableBinding.USED; |
81 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=318571 |
82 |
} else if (localBinding.useFlag == LocalVariableBinding.UNUSED) { |
82 |
// access from compound assignment does not prevent "unused" warning, unless unboxing is involved: |
83 |
localBinding.useFlag = LocalVariableBinding.FAKE_USED; |
83 |
if (isReachable && (this.implicitConversion & TypeIds.UNBOXING) != 0) { |
|
|
84 |
localBinding.useFlag = LocalVariableBinding.USED; |
85 |
} else { |
86 |
localBinding.useFlag = LocalVariableBinding.FAKE_USED; |
87 |
} |
84 |
} |
88 |
} |
85 |
} |
89 |
} |
86 |
} |
90 |
} |
Lines 461-466
Link Here
|
461 |
* are optimized in one access: e.g "a = a + 1" optimized into "a++". |
465 |
* are optimized in one access: e.g "a = a + 1" optimized into "a++". |
462 |
*/ |
466 |
*/ |
463 |
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { |
467 |
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { |
|
|
468 |
if (!valueRequired && ((this.bits & ASTNode.RestrictiveFlagMASK) == Binding.LOCAL)) { |
469 |
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; |
470 |
if (localBinding.useFlag == LocalVariableBinding.FAKE_USED) { |
471 |
// report the case of a local variable that is unread except for this compound assignment |
472 |
currentScope.problemReporter().unusedLocalVariable(localBinding.declaration); |
473 |
localBinding.useFlag = LocalVariableBinding.USED; // don't report again |
474 |
} |
475 |
} |
464 |
this.generateCompoundAssignment( |
476 |
this.generateCompoundAssignment( |
465 |
currentScope, |
477 |
currentScope, |
466 |
codeStream, |
478 |
codeStream, |
Lines 661-666
Link Here
|
661 |
return; |
673 |
return; |
662 |
case Binding.LOCAL : // assigning to a local variable |
674 |
case Binding.LOCAL : // assigning to a local variable |
663 |
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; |
675 |
LocalVariableBinding localBinding = (LocalVariableBinding) this.binding; |
|
|
676 |
|
677 |
if (!valueRequired) { |
678 |
if (localBinding.useFlag == LocalVariableBinding.FAKE_USED) { |
679 |
// report the case of a local variable that is unread except for postIncrement expressions |
680 |
currentScope.problemReporter().unusedLocalVariable(localBinding.declaration); |
681 |
localBinding.useFlag = LocalVariableBinding.USED; // don't report again |
682 |
} |
683 |
} |
684 |
|
664 |
// using incr bytecode if possible |
685 |
// using incr bytecode if possible |
665 |
if (localBinding.type == TypeBinding.INT) { |
686 |
if (localBinding.type == TypeBinding.INT) { |
666 |
if (valueRequired) { |
687 |
if (valueRequired) { |