@@ -1529,7 +1529,7 @@ private void checkReassignmentToField(Set<Obligation> obligations, AssignmentNod
15291529 if (Objects .equals (enclosingClassElement , receiverElement )) {
15301530 VariableElement lhsElement = lhs .getElement ();
15311531 if (lhsElement .getModifiers ().contains (Modifier .PRIVATE )
1532- && isOnlyAssignmentToField (lhsElement , enclosingMethodTree , node .getTree ())) {
1532+ && isFirstAndOnlyAssignmentToField (lhsElement , enclosingMethodTree , node .getTree ())) {
15331533 return ;
15341534 }
15351535 }
@@ -1680,7 +1680,7 @@ && varTrackedInObligations(obligations, (LocalVariableNode) receiver))
16801680 * @return true if this assignment can be safely considered the first and only one during
16811681 * construction
16821682 */
1683- private boolean isOnlyAssignmentToField (
1683+ private boolean isFirstAndOnlyAssignmentToField (
16841684 VariableElement field , MethodTree constructor , @ FindDistinct Tree currentAssignment ) {
16851685 @ Nullable TreePath constructorPath = cmAtf .getPath (constructor );
16861686 ClassTree classTree = TreePathUtil .enclosingClass (constructorPath );
@@ -1703,6 +1703,8 @@ private boolean isOnlyAssignmentToField(
17031703 if (member instanceof BlockTree ) {
17041704 BlockTree block = (BlockTree ) member ;
17051705 if (block .isStatic ()) continue ;
1706+ // The variables accessed from within the inner class need to be effectively final, so
1707+ // AtomicBoolean is used here.
17061708 AtomicBoolean found = new AtomicBoolean (false );
17071709 block .accept (
17081710 new TreeScanner <Void , Void >() {
0 commit comments