@@ -1529,7 +1529,7 @@ private void checkReassignmentToField(Set<Obligation> obligations, AssignmentNod
1529
1529
if (Objects .equals (enclosingClassElement , receiverElement )) {
1530
1530
VariableElement lhsElement = lhs .getElement ();
1531
1531
if (lhsElement .getModifiers ().contains (Modifier .PRIVATE )
1532
- && isOnlyAssignmentToField (lhsElement , enclosingMethodTree , node .getTree ())) {
1532
+ && isFirstAndOnlyAssignmentToField (lhsElement , enclosingMethodTree , node .getTree ())) {
1533
1533
return ;
1534
1534
}
1535
1535
}
@@ -1680,7 +1680,7 @@ && varTrackedInObligations(obligations, (LocalVariableNode) receiver))
1680
1680
* @return true if this assignment can be safely considered the first and only one during
1681
1681
* construction
1682
1682
*/
1683
- private boolean isOnlyAssignmentToField (
1683
+ private boolean isFirstAndOnlyAssignmentToField (
1684
1684
VariableElement field , MethodTree constructor , @ FindDistinct Tree currentAssignment ) {
1685
1685
@ Nullable TreePath constructorPath = cmAtf .getPath (constructor );
1686
1686
ClassTree classTree = TreePathUtil .enclosingClass (constructorPath );
@@ -1703,6 +1703,8 @@ private boolean isOnlyAssignmentToField(
1703
1703
if (member instanceof BlockTree ) {
1704
1704
BlockTree block = (BlockTree ) member ;
1705
1705
if (block .isStatic ()) continue ;
1706
+ // The variables accessed from within the inner class need to be effectively final, so
1707
+ // AtomicBoolean is used here.
1706
1708
AtomicBoolean found = new AtomicBoolean (false );
1707
1709
block .accept (
1708
1710
new TreeScanner <Void , Void >() {
0 commit comments