Get a capture variable's upper bound, returning other types unchanged.
@param t a type
483709
public Type cvarUpperBound(Type t) {
        if (t.hasTag(TYPEVAR)) {
            TypeVar v = (TypeVar) t;
            return v.isCaptured() ? cvarUpperBound(v.bound) : v;
        }
        else return t;
    }
380467
public static TypeVariableConstraint withVariadicBound(String name, String variadicBound)
    {
        return new TypeVariableConstraint(name, false, false, variadicBound);
    }
569840
public List<Type> getBounds(TypeVar t) {
        if (t.bound.hasTag(NONE))
            return List.nil();
        else if (t.bound.isErroneous() || !t.bound.isCompound())
            return List.of(t.bound);
        else if ((erasure(t).tsym.flags() & INTERFACE) == 0)
            return interfaces(t).prepend(supertype(t));
        else
            // No superclass was given in bounds.
            // In this case, supertype is Object, erasure is first interface.
            return interfaces(t);
    }
630225
public TypeBindings withUnboundVariable(String name)
    {
        int len = (_unboundVariables == null) ? 0 : _unboundVariables.length;
        String[] names =  (len == 0)
                ? new String[1] : Arrays.copyOf(_unboundVariables, len+1);
        names[len] = name;
        return new TypeBindings(_names, _types, names);
    }
57457
@SuppressWarnings("unchecked")
    public static <T extends Type> T unwrap(T type) {
        Type unwrapped = type;
        while (unwrapped instanceof SerializableTypeProxy) {
            unwrapped = ((SerializableTypeProxy) type).getTypeProvider().getType();
        }
        return (T) unwrapped;
    }
621847
public static <T> T checkAndGet(T value, T defaultValue, Validator<T> v) {
		if (v.validate(value)) {
			return value;
		}

		return defaultValue;
	}
1126670
public void add(int var, Type t) {
    Set<Integer> tVars = t.getTypeVariables();
    Set<Integer> intersection = Sets.intersection(tVars, bindings.keySet());
    Preconditions.checkArgument(intersection.size() == 0,
        "Tried to replace %s with %s, but already have bindings for %s", var, t, intersection);
    Preconditions.checkArgument(!tVars.contains(var),
        "Recursive replacement: tried to replace %s with %s", var, t);
    
    Map<Integer, Type> newBinding = Maps.newHashMap();
    newBinding.put(var, t);
    for (int boundVar : bindings.keySet()) {
      bindings.put(boundVar, bindings.get(boundVar).substitute(newBinding));
    }
    bindings.put(var, t);
  }
1229353
public boolean containedBy(Type t, Type s) {
        switch (t.getTag()) {
        case UNDETVAR:
            if (s.hasTag(WILDCARD)) {
                UndetVar undetvar = (UndetVar)t;
                WildcardType wt = (WildcardType)s;
                switch(wt.kind) {
                    case UNBOUND:
                        break;
                    case EXTENDS: {
                        Type bound = wildUpperBound(s);
                        undetvar.addBound(InferenceBound.UPPER, bound, this);
                        break;
                    }
                    case SUPER: {
                        Type bound = wildLowerBound(s);
                        undetvar.addBound(InferenceBound.LOWER, bound, this);
                        break;
                    }
                }
                return true;
            } else {
                return isSameType(t, s);
            }
        case ERROR:
            return true;
        default:
            return containsType(s, t);
        }
    }
242598
public static Type resolveAt(Object o, TypeVariable<?> var) {
        Validate.notNull(var, "no variable to read");
        final GenericDeclaration genericDeclaration = var.getGenericDeclaration();
        Validate.isInstanceOf(Class.class, genericDeclaration, "%s is not declared by a Class",
            TypeUtils.toLongString(var));
        return resolveAt(o, var, TypeUtils.getTypeArguments(o.getClass(), (Class<?>) genericDeclaration));
    }
541444
def getLong(t):
    
    i = c_long()
    if PL_get_long(t, byref(i)):
        return i.value
    else:
        raise InvalidTypeError("long")
1125094
static StackTraceElement[] getStackTrace(final Thread t)
   {
      if (System.getSecurityManager() == null)
         return t.getStackTrace();

      return AccessController.doPrivileged(new PrivilegedAction<StackTraceElement[]>() 
      {
         public StackTraceElement[] run()
         {
            return t.getStackTrace();
         }
      });
   }
758837
def get_bounds(self, which, dimension):
        """"""
        if which == 'lower' or which == 0:
            return self._get_bounds(0, dimension)
        elif which == 'upper' or which == 1:
            return self._get_bounds(1, dimension)
        else:
            raise ValueError("argument which must be 'lower' or 'upper'")
1050809
private static boolean isVariableInteger(TokenList.Token t) {
        if( t == null )
            return false;

        return t.getScalarType() == VariableScalar.Type.INTEGER;
    }
478908
public List<Type> capture(List<Type> ts) {
        List<Type> buf = List.nil();
        for (Type t : ts) {
            buf = buf.prepend(capture(t));
        }
        return buf.reverse();
    }
434169
@SuppressWarnings("unchecked")
    public <T extends WindupVertexFrame> Iterable<T> findVariableOfType(Class<T> type)
    {
        for (Map<String, Iterable<? extends WindupVertexFrame>> topOfStack : deque)
        {
            for (Iterable<? extends WindupVertexFrame> frames : topOfStack.values())
            {
                boolean empty = true;
                for (WindupVertexFrame frame : frames)
                {
                    if (!type.isAssignableFrom(frame.getClass()))
                    {
                        break;
                    }
                    else
                    {
                        empty = false;
                    }
                }
                // now we know all the frames are of the chosen type
                if (!empty)
                    return (Iterable<T>) frames;
            }
        }
        return null;
    }
234056
private Type getAppropriateType(Class<?> type, Type genericType)
    {    
        return type.equals(genericType) ? type : genericType;
    }
1199866
public static WildcardType subtypeOf(Type bound) {
    final TypeVariable<?> var = TypeVariableGenerator.freshTypeVariable("B");
    return (WildcardType) new TypeResolver().where(var, bound).resolveType(new WildcardType() {
      @Override public Type[] getUpperBounds() { return new Type[] {var}; }
      @Override public Type[] getLowerBounds() { return new Type[0]; }
    });
  }