Exemple #1
0
 // When joining w/ TOP or UNKNOWN, avoid setting more fields on them, eg, obj.
 public static JSType join(JSType lhs, JSType rhs) {
   if (lhs.isTop() || rhs.isTop()) {
     return TOP;
   } else if (lhs.isUnknown() || rhs.isUnknown()) {
     return UNKNOWN;
   } else if (lhs.isBottom()) {
     return rhs;
   } else if (rhs.isBottom()) {
     return lhs;
   }
   if (lhs.typeVar != null && rhs.typeVar != null && !lhs.typeVar.equals(rhs.typeVar)) {
     // For now return ? when joining two type vars. This is probably uncommon.
     return UNKNOWN;
   }
   return new JSType(
       lhs.mask | rhs.mask,
       joinLocs(lhs.location, rhs.location),
       ObjectType.joinSets(lhs.objs, rhs.objs),
       lhs.typeVar != null ? lhs.typeVar : rhs.typeVar);
 }