closure-compiler/src/com/google/javascript/rhino/jstype/JSType.java
/**
   * When computing infima, we may get a situation like
   * inf(Type1, Type2)
   * where both types are unresolved, so they're technically
   * subtypes of one another.
   *
   * If this happens, filter them down to NoResolvedType.
   */
When computing infima, we may get a situation like
inf(Type1, Type2)
where both types are unresolved, so they're technically
subtypes of one another.

If this happens, filter them down to NoResolvedType.
When computing infima we may get a situation like inf ( Type1 Type2 ) where both types are unresolved so they ' re technically subtypes of one another . If this happens filter them down to NoResolvedType .
static JSType filterNoResolvedType(JSType type) {
    if (type.isNoResolvedType()) {
      return type.getNativeType(JSTypeNative.NO_RESOLVED_TYPE);
    } else if (type.isUnionType()) {
      UnionType unionType = type.toMaybeUnionType();
      boolean needsFiltering = false;
      ImmutableList<JSType> alternatesList = unionType.getAlternates();
      for (int i = 0; i < alternatesList.size(); i++) {
        JSType alt = alternatesList.get(i);
        if (alt.isNoResolvedType()) {
          needsFiltering = true;
          break;
        }
      }
      if (needsFiltering) {
        UnionTypeBuilder builder = UnionTypeBuilder.create(type.registry);
        builder.addAlternate(type.getNativeType(JSTypeNative.NO_RESOLVED_TYPE));
        for (int i = 0; i < alternatesList.size(); i++) {
          JSType alt = alternatesList.get(i);
          if (!alt.isNoResolvedType()) {
            builder.addAlternate(alt);
          }
        }
        return builder.build();
      }
    }
    return type;
  }
static JSType filterNoResolvedType ( JSType type ) { if ( type . isNoResolvedType ( ) ) { return type . getNativeType ( JSTypeNative . NO_RESOLVED_TYPE ) ; } else if ( type . isUnionType ( ) ) { UnionType unionType = type . toMaybeUnionType ( ) ; boolean needsFiltering = false ; ImmutableList < JSType > alternatesList = unionType . getAlternates ( ) ; for ( int i = 0 ; i < alternatesList . size ( ) ; i ++ ) { JSType alt = alternatesList . get ( i ) ; if ( alt . isNoResolvedType ( ) ) { needsFiltering = true ; break ; } } if ( needsFiltering ) { UnionTypeBuilder builder = UnionTypeBuilder . create ( type . registry ) ; builder . addAlternate ( type . getNativeType ( JSTypeNative . NO_RESOLVED_TYPE ) ) ; for ( int i = 0 ; i < alternatesList . size ( ) ; i ++ ) { JSType alt = alternatesList . get ( i ) ; if ( ! alt . isNoResolvedType ( ) ) { builder . addAlternate ( alt ) ; } } return builder . build ( ) ; } } return type ; }
When computing infima, we may get a situation like
 inf(Type1, Type2)
 where both types are unresolved, so they're technically
 subtypes of one another.
When computing infima we may get a situation like inf ( Type1 Type2 ) where both types are unresolved so they ' re technically subtypes of one another .
// inf(UnresolvedType1, UnresolvedType2) needs to resolve // to the base unresolved type, so that the relation is symmetric.