private static Type resolveTypeVariable(
      Type context, Class<?> contextRawType, TypeVariable<?> unknown) {
    Class<?> declaredByRaw = declaringClassOf(unknown);

    // We can't reduce this further.
    if (declaredByRaw == null) {
      return unknown;
    }

    Type declaredBy = getGenericSupertype(context, contextRawType, declaredByRaw);
    if (declaredBy instanceof ParameterizedType) {
      int index = indexOf(declaredByRaw.getTypeParameters(), unknown);
      return ((ParameterizedType) declaredBy).getActualTypeArguments()[index];
    }

    return unknown;
  }
Returns the generic form of {@code supertype}. For example, if this is {@code
ArrayList<String>}, this returns {@code Iterable<String>} given the input {@code
Iterable.class}.

@param supertype a superclass of, or interface implemented by, this.
core/src/main/java/feign/Types.java