Creates a union type whose variants are the built-in types specified
by the arguments.
359749
public JSType createUnionType(JSTypeNative... variants) {
    UnionTypeBuilder builder = UnionTypeBuilder.create(this);
    for (JSTypeNative typeId : variants) {
      builder.addAlternate(getNativeType(typeId));
    }
    return builder.build();
  }
140368
private ImmutableList<UTypeVar> freeTypeVars(Unifier unifier) {
    ImmutableList.Builder<UTypeVar> builder = ImmutableList.builder();
    for (UTypeVar var : typeVariables(unifier.getContext())) {
      if (unifier.getBinding(var.key()) == null) {
        builder.add(var);
      }
    }
    return builder.build();
  }
1246403
function createCombi (types, options) {
    var tests = types.map(function (type) {
      return ducktype(type).test;
    });

    return new DuckType({
      name: options && options.name || null,
      test: function test (object) {
        for (var i = 0, ii = tests.length; i < ii; i++) {
          if (tests[i](object)) {
            return true;
          }
        }
        return false;
      }
    });
  }
491618
function getUnionTypeFromSortedList(types, aliasSymbol, aliasTypeArguments) {
            if (types.length === 0) {
                return neverType;
            }
            if (types.length === 1) {
                return types[0];
            }
            var id = getTypeListId(types);
            var type = unionTypes[id];
            if (!type) {
                var propagatedFlags = getPropagatingFlagsOfTypes(types, /*excludeKinds*/ 6144 /* Nullable */);
                type = unionTypes[id] = createObjectType(524288 /* Union */ | propagatedFlags);
                type.types = types;
                type.aliasSymbol = aliasSymbol;
                type.aliasTypeArguments = aliasTypeArguments;
            }
            return type;
        }
78874
def _issubclass_Union(subclass, superclass, bound_Generic, bound_typevars,
            bound_typevars_readonly, follow_fwd_refs, _recursion_check):
    
    if not follow_fwd_refs:
        return _issubclass_Union_rec(subclass, superclass, bound_Generic, bound_typevars,
            bound_typevars_readonly, follow_fwd_refs, _recursion_check)
    try:
        # try to succeed fast, before we go the expensive way involving recursion checks
        return _issubclass_Union_rec(subclass, superclass, bound_Generic, bound_typevars,
            bound_typevars_readonly, False, _recursion_check)
    except pytypes.ForwardRefError:
        return _issubclass_Union_rec(subclass, superclass, bound_Generic, bound_typevars,
            bound_typevars_readonly, follow_fwd_refs, _recursion_check)
967902
public static ParameterizedType newParameterizedType(
      final Class<?> raw, Iterable<? extends Type> typeArgs) {
    TypeResolver resolver = new TypeResolver();
    final List<TypeVariable<?>> vars = new ArrayList<TypeVariable<?>>();
    for (Type arg : typeArgs) {
      TypeVariable<?> var = TypeVariableGenerator.freshTypeVariable("T" + vars.size());
      vars.add(var);
      resolver = resolver.where(var, arg);
    }
    checkArgument(raw.getTypeParameters().length == vars.size(),
        "%s expected %s type parameters, while %s are provied",
        raw, raw.getTypeParameters().length, typeArgs);
    return (ParameterizedType) resolver.resolveType(new ParameterizedType() {
      @Override public Class<?> getRawType() { return raw; }
      @Override public Type getOwnerType() { return null; }
      @Override public Type[] getActualTypeArguments() { return vars.toArray(new Type[0]); }
    });
  }
925718
private Class[] makeParameterTypes(Object owner, MetaMethod m) {
        Class[] newParameterTypes;

        if (owner instanceof Class && !m.isStatic()) {
            Class[] nativeParameterTypes = m.getNativeParameterTypes();
            newParameterTypes = new Class[nativeParameterTypes.length + 1];

            System.arraycopy(nativeParameterTypes, 0, newParameterTypes, 1, nativeParameterTypes.length);
            newParameterTypes[0] = (Class) owner;
        } else {
            newParameterTypes = m.getNativeParameterTypes();
        }

        return newParameterTypes;
    }
1336842
def _create_array(self, format, args):
        """"""

        builder = None
        if args is None or not args[0]:
            # empty value: we need to call _create() to parse the subtype,
            # and specify the element type precisely
            rest_format = self._create(format[1:], None)[1]
            element_type = format[:len(format) - len(rest_format)]
            builder = GLib.VariantBuilder.new(variant_type_from_string(element_type))
        else:
            builder = GLib.VariantBuilder.new(variant_type_from_string('a*'))
            for i in range(len(args[0])):
                (v, rest_format, _) = self._create(format[1:], args[0][i:])
                builder.add_value(v)
        if args is not None:
            args = args[1:]
        return (builder.end(), rest_format, args)
935375
def _unionload(l: Loader, value, type_) -> Any:
    
    try:
        args = uniontypes(type_)
    except AttributeError:
        raise TypedloadAttributeError('The typing API for this Python version is unknown')

    # Do not convert basic types, if possible
    if type(value) in args.intersection(l.basictypes):
        return value

    exceptions = []

    # Try all types
    for t in args:
        try:
            return l.load(value, t, annotation=Annotation(AnnotationType.UNION, t))
        except Exception as e:
            exceptions.append(e)
    raise TypedloadValueError(
        'Value could not be loaded into %s' % type_,
            value=value,
            type_=type_,
            exceptions=exceptions
    )
437642
function createUnionTypeAnnotation(types) {
  var flattened = removeTypeDuplicates(types);

  if (flattened.length === 1) {
    return flattened[0];
  } else {
    return t.unionTypeAnnotation(flattened);
  }
}
732459
private static void createLocales(TypeSpec.Builder type, List<LocaleID> defaultContent, Set<LocaleID> available) {
    TypeSpec.Builder localeInterface = TypeSpec.interfaceBuilder("Locale")
        .addModifiers(PUBLIC, STATIC)
        .addMethod(MethodSpec.methodBuilder("language")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("script")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("territory")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("variant")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("compact")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build())
        .addMethod(MethodSpec.methodBuilder("expanded")
            .addModifiers(PUBLIC, ABSTRACT)
            .returns(String.class).build());
    
    List<LocaleID> localeFields = new ArrayList<>();
    List<String> allLocales = new ArrayList<>();
    List<String> bundles = new ArrayList<>();
    
    for (LocaleID locale : available) {
      localeFields.add(locale);
      allLocales.add(locale.safe);
      bundles.add(locale.safe);
    }
    
    MethodSpec.Builder method = MethodSpec.methodBuilder("registerDefaultContent")
        .addModifiers(PRIVATE, STATIC);
    
    for (LocaleID locale : defaultContent) {
      LocaleID dest = new LocaleID(locale.language, "", "", "");
      if (available.contains(dest)) {
        localeFields.add(locale);
        allLocales.add(locale.safe);
        method.addStatement("DEFAULT_CONTENT.put(Locale.$L, Locale.$L)",
            locale.safe,
            dest.safe);
      }
    }
    type.addMethod(method.build());

    Collections.sort(localeFields);
    for (LocaleID locale : localeFields) {
      addLocaleField(localeInterface, locale.safe, locale);
    }

    StringBuilder buf = new StringBuilder("$T.unmodifiableList($T.asList(\n");
    for (int i = 0; i < allLocales.size(); i++) {
      if (i > 0) {
        buf.append(",\n");
      }
      buf.append("  Locale.$L");
    }
    buf.append("))");

    Collections.sort(allLocales);
    
    List<Object> arguments = new ArrayList<>();
    arguments.add(Collections.class);
    arguments.add(Arrays.class);
    arguments.addAll(allLocales);
    
    FieldSpec.Builder field = FieldSpec.builder(LIST_CLDR_LOCALE_IF, "AVAILABLE_LOCALES", PRIVATE, STATIC, FINAL);
    field.initializer(buf.toString(), arguments.toArray());
    type.addField(field.build());
    
    buf = new StringBuilder("$T.unmodifiableList($T.asList(\n");
    for (int i = 0; i < bundles.size(); i++) {
      if (i > 0) {
        buf.append(",\n");
      }
      buf.append("  Locale.$L");
    }
    buf.append("))");
    
    Collections.sort(bundles);
    arguments = new ArrayList<>();
    arguments.add(Collections.class);
    arguments.add(Arrays.class);
    arguments.addAll(bundles);
    
    field = FieldSpec.builder(LIST_CLDR_LOCALE_IF, "AVAILABLE_BUNDLES", PRIVATE, STATIC, FINAL);
    field.initializer(buf.toString(), arguments.toArray());
    type.addField(field.build());
    
    method = MethodSpec.methodBuilder("availableLocales")
        .addModifiers(PUBLIC, FINAL)
        .returns(LIST_CLDR_LOCALE_IF)
        .addStatement("return AVAILABLE_LOCALES");
    
    type.addMethod(method.build());
    
    method = MethodSpec.methodBuilder("availableBundles")
        .addModifiers(PUBLIC, FINAL)
        .returns(LIST_CLDR_LOCALE_IF)
        .addStatement("return AVAILABLE_BUNDLES");
    
    type.addMethod(method.build());

    type.addType(localeInterface.build());
  }
823970
void heterogenousUnion(final HLL other) {
        /*
         * The logic here is divided into two sections: unions with an EMPTY
         * HLL, and unions between EXPLICIT/SPARSE/FULL
         * HLL.
         *
         * Between those two sections, all possible heterogeneous unions are
         * covered. Should another type be added to HLLType whose unions
         * are not easily reduced (say, as EMPTY's are below) this may be more
         * easily implemented as Strategies. However, that is unnecessary as it
         * stands.
         */

        // ....................................................................
        // Union with an EMPTY
        if(HLLType.EMPTY.equals(type)) {
            // NOTE:  The union of empty with non-empty HLL is just a
            //        clone of the non-empty.

            switch(other.getType()) {
                case EXPLICIT: {
                    // src:  EXPLICIT
                    // dest: EMPTY

                    if(other.explicitStorage.size() <= explicitThreshold) {
                        type = HLLType.EXPLICIT;
                        explicitStorage = other.explicitStorage.clone();
                    } else {
                        if(!sparseOff) {
                            initializeStorage(HLLType.SPARSE);
                        } else {
                            initializeStorage(HLLType.FULL);
                        }
                        for(final long value : other.explicitStorage) {
                            addRaw(value);
                        }
                    }
                    return;
                }
                case SPARSE: {
                    // src:  SPARSE
                    // dest: EMPTY

                    if(!sparseOff) {
                        type = HLLType.SPARSE;
                        sparseProbabilisticStorage = other.sparseProbabilisticStorage.clone();
                    } else {
                        initializeStorage(HLLType.FULL);
                        for(final int registerIndex : other.sparseProbabilisticStorage.keySet()) {
                            final byte registerValue = other.sparseProbabilisticStorage.get(registerIndex);
                            probabilisticStorage.setMaxRegister(registerIndex, registerValue);
                        }
                    }
                    return;
                }
                default/*case FULL*/: {
                    // src:  FULL
                    // dest: EMPTY

                    type = HLLType.FULL;
                    probabilisticStorage = other.probabilisticStorage.clone();
                    return;
                }
            }
        } else if (HLLType.EMPTY.equals(other.getType())) {
            // source is empty, so just return destination since it is unchanged
            return;
        } /* else -- both of the sets are not empty */

        // ....................................................................
        // NOTE: Since EMPTY is handled above, the HLLs are non-EMPTY below
        switch(type) {
            case EXPLICIT: {
                // src:  FULL/SPARSE
                // dest: EXPLICIT
                // "Storing into destination" cannot be done (since destination
                // is by definition of smaller capacity than source), so a clone
                // of source is made and values from destination are inserted
                // into that.

                // Determine source and destination storage.
                // NOTE:  destination storage may change through promotion if
                //        source is SPARSE.
                if(HLLType.SPARSE.equals(other.getType())) {
                    if(!sparseOff) {
                        type = HLLType.SPARSE;
                        sparseProbabilisticStorage = other.sparseProbabilisticStorage.clone();
                    } else {
                        initializeStorage(HLLType.FULL);
                        for(final int registerIndex : other.sparseProbabilisticStorage.keySet()) {
                            final byte registerValue = other.sparseProbabilisticStorage.get(registerIndex);
                            probabilisticStorage.setMaxRegister(registerIndex, registerValue);
                        }
                    }
                } else /*source is HLLType.FULL*/ {
                    type = HLLType.FULL;
                    probabilisticStorage = other.probabilisticStorage.clone();
                }
                for(final long value : explicitStorage) {
                    addRaw(value);
                }
                explicitStorage = null;
                return;
            }
            case SPARSE: {
                if(HLLType.EXPLICIT.equals(other.getType())) {
                    // src:  EXPLICIT
                    // dest: SPARSE
                    // Add the raw values from the source to the destination.

                    for(final long value : other.explicitStorage) {
                        addRaw(value);
                    }
                    // NOTE:  addRaw will handle promotion cleanup
                } else /*source is HLLType.FULL*/ {
                    // src:  FULL
                    // dest: SPARSE
                    // "Storing into destination" cannot be done (since destination
                    // is by definition of smaller capacity than source), so a
                    // clone of source is made and registers from the destination
                    // are merged into the clone.

                    type = HLLType.FULL;
                    probabilisticStorage = other.probabilisticStorage.clone();
                    for(final int registerIndex : sparseProbabilisticStorage.keySet()) {
                        final byte registerValue = sparseProbabilisticStorage.get(registerIndex);
                        probabilisticStorage.setMaxRegister(registerIndex, registerValue);
                    }
                    sparseProbabilisticStorage = null;
                }
                return;
            }
            default/*destination is HLLType.FULL*/: {
                if(HLLType.EXPLICIT.equals(other.getType())) {
                    // src:  EXPLICIT
                    // dest: FULL
                    // Add the raw values from the source to the destination.
                    // Promotion is not possible, so don't bother checking.

                    for(final long value : other.explicitStorage) {
                        addRaw(value);
                    }
                } else /*source is HLLType.SPARSE*/ {
                    // src:  SPARSE
                    // dest: FULL
                    // Merge the registers from the source into the destination.
                    // Promotion is not possible, so don't bother checking.

                    for(final int registerIndex : other.sparseProbabilisticStorage.keySet()) {
                        final byte registerValue = other.sparseProbabilisticStorage.get(registerIndex);
                        probabilisticStorage.setMaxRegister(registerIndex, registerValue);
                    }
                }

            }
        }
    }
220808
public static ParameterizedType parameterizedType(Type ownerType, Type rawType,
            Type... typeArguments) {
        return newParameterizedTypeWithOwner(ownerType, rawType, typeArguments);
    }
982381
def merge(self, other):
        
        if not isinstance(other, NameVariants):
            raise TypeError("NameVariants isinstance can be merge with"
                            "other isinstance of the same class")
        for key in self.variants:
            self.variants[key] = self.variants[key] or other.variants[key]

        return self
987483
function combineStrings(types, opts) {
  var symbols = {};
  var i, l, type, typeSymbols;
  for (i = 0, l = types.length; i < l; i++) {
    type = types[i];
    if (type.getTypeName() === 'string') {
      // If at least one of the types is a string, it will be the supertype.
      return type;
    }
    typeSymbols = type.getSymbols();
    var j, m;
    for (j = 0, m = typeSymbols.length; j < m; j++) {
      symbols[typeSymbols[j]] = true;
    }
  }
  return createType({type: 'enum', symbols: Object.keys(symbols)}, opts);
}
877681
public final Coalesce<T> coalesce(T... args) {
        Coalesce<T> coalesce = new Coalesce<T>(getType(), mixin);
        for (T arg : args) {
            coalesce.add(arg);
        }
        return coalesce;
    }
50468
private void genOptTypeArguments(List<? extends TypeMirror> typeArguments, StringBuilder sb) {
    if (!typeArguments.isEmpty()) {
      sb.append('<');
      for (TypeMirror typeParam : typeArguments) {
        genTypeSignature(typeParam, sb);
      }
      sb.append('>');
    }
  }