code: private boolean checkForBadModuleReference(Name name, Ref ref) {
      JSModuleGraph moduleGraph = compiler.getModuleGraph();
      if (name.getGlobalSets() == 0 || ref.type == Ref.Type.SET_FROM_GLOBAL) {
        // Back off if either 1) this name was never set, or 2) this reference /is/ a set.
        return false;
      }
      if (name.getGlobalSets() == 1) {
        // there is only one global set - it should be set as name.declaration
        // just look at that declaration instead of iterating through every single reference.
        Ref declaration = checkNotNull(name.getDeclaration());
        return !isSetFromPrecedingModule(ref, declaration, moduleGraph);
      }
      // there are multiple sets, so check if any of them happens in this module or a module earlier
      // in the dependency chain.
      for (Ref set : name.getRefs()) {
        if (isSetFromPrecedingModule(ref, set, moduleGraph)) {
          return false;
        }
      }
      return true;
    }
docs: Returns true if this name is potentially referenced before being defined in a different module
  
  <p>For example:
  
  <ul>
  <li>Module B depends on Module A. name is set in Module A and referenced in Module B. this is
  fine, and this method returns false.
  <li>Module A and Module B are unrelated. name is set in Module A and referenced in Module B.
  this is an error, and this method returns true.
  <li>name is referenced in Module A, and never set globally. This warning is not specific to
  modules, so is emitted elsewhere.
  </ul>