code: private void updateTwinnedDeclaration(String alias, Name refName, Ref ref) {
      checkNotNull(ref.getTwin());
      // Don't handle declarations of an already flat name, just qualified names.
      if (!ref.getNode().isGetProp()) {
        return;
      }
      Node rvalue = ref.getNode().getNext();
      Node parent = ref.getNode().getParent();
      Node grandparent = parent.getParent();
  
      if (rvalue != null && rvalue.isFunction()) {
        checkForHosedThisReferences(rvalue, refName.getJSDocInfo(), refName);
      }
  
      // Create the new alias node.
      Node nameNode =
          NodeUtil.newName(compiler, alias, grandparent.getFirstChild(), refName.getFullName());
      NodeUtil.copyNameAnnotations(ref.getNode().getLastChild(), nameNode);
  
      // BEFORE:
      // ... (x.y = 3);
      //
      // AFTER:
      // var x$y;
      // ... (x$y = 3);
  
      Node current = grandparent;
      Node currentParent = grandparent.getParent();
      for (;
          !currentParent.isScript() && !currentParent.isBlock();
          current = currentParent, currentParent = currentParent.getParent()) {}
  
      // Create a stub variable declaration right
      // before the current statement.
      Node stubVar = IR.var(nameNode.cloneTree()).useSourceInfoIfMissingFrom(nameNode);
      currentParent.addChildBefore(stubVar, current);
  
      parent.replaceChild(ref.getNode(), nameNode);
      compiler.reportChangeToEnclosingScope(nameNode);
    }
docs: Updates the initial assignment to a collapsible property at global scope
  by adding a VAR stub and collapsing the property. e.g. c = a.b = 1; => var a$b; c = a$b = 1;
  This specifically handles "twinned" assignments, which are those where the assignment is also
  used as a reference and which need special handling.
  
  @param alias The flattened property name (e.g. "a$b")
  @param refName The name for the reference being updated.
  @param ref An object containing information about the assignment getting updated