src/com/google/javascript/rhino/jstype/UnionType.java
/**
   * Two union types are equal if, after flattening nested union types, they have the same number of
   * alternatesCollapsingStructuralSubtypes and all alternatesCollapsingStructuralSubtypes are
   * equal.
   */
Two union types are equal if, after flattening nested union types, they have the same number of
alternatesCollapsingStructuralSubtypes and all alternatesCollapsingStructuralSubtypes are
equal.
Two union types are equal if after flattening nested union types they have the same number of alternatesCollapsingStructuralSubtypes and all alternatesCollapsingStructuralSubtypes are equal .
boolean checkUnionEquivalenceHelper(UnionType that, EquivalenceMethod eqMethod, EqCache eqCache) {
    List<JSType> thatAlternates = that.getAlternatesWithoutStructuralTyping();
    if (eqMethod == EquivalenceMethod.IDENTITY
        && getAlternatesWithoutStructuralTyping().size() != thatAlternates.size()) {
      return false;
    }
    for (int i = 0; i < thatAlternates.size(); i++) {
      JSType thatAlternate = thatAlternates.get(i);
      if (!hasAlternate(thatAlternate, eqMethod, eqCache)) {
        return false;
      }
    }
    return true;
  }
boolean checkUnionEquivalenceHelper ( UnionType that , EquivalenceMethod eqMethod , EqCache eqCache ) { List < JSType > thatAlternates = that . getAlternatesWithoutStructuralTyping ( ) ; if ( eqMethod == EquivalenceMethod . IDENTITY && getAlternatesWithoutStructuralTyping ( ) . size ( ) != thatAlternates . size ( ) ) { return false ; } for ( int i = 0 ; i < thatAlternates . size ( ) ; i ++ ) { JSType thatAlternate = thatAlternates . get ( i ) ; if ( ! hasAlternate ( thatAlternate , eqMethod , eqCache ) ) { return false ; } } return true ; }
Two union types are equal if, after flattening nested union types, they have the same number of
 alternatesCollapsingStructuralSubtypes and all alternatesCollapsingStructuralSubtypes are
 equal.
Two union types are equal if after flattening nested union types they have the same number of alternatesCollapsingStructuralSubtypes and all alternatesCollapsingStructuralSubtypes are equal .