private static ImmutableSet<TypeVariableName> getMethodTypeVariables(
      FactoryMethodDescriptor methodDescriptor,
      ImmutableSet<TypeVariableName> factoryTypeVariables) {
    ImmutableSet.Builder<TypeVariableName> typeVariables = ImmutableSet.builder();
    typeVariables.addAll(getReferencedTypeParameterNames(methodDescriptor.returnType()));
    for (Parameter parameter : methodDescriptor.passedParameters()) {
      typeVariables.addAll(getReferencedTypeParameterNames(parameter.type().get()));
    }
    return Sets.difference(typeVariables.build(), factoryTypeVariables).immutableCopy();
  }
Returns an appropriate {@code TypeName} for the given type. If the type is an {@code
ErrorType}, and if it is a simple-name reference to one of the {@code *Factory} classes that we
are going to generate, then we return its fully-qualified name. In every other case we just
return {@code TypeName.get(type)}. Specifically, if it is an {@code ErrorType} referencing some
other type, or referencing one of the classes we are going to generate but using its
fully-qualified name, then we leave it as-is. JavaPoet treats {@code TypeName.get(t)} the same
for {@code ErrorType} as for {@code DeclaredType}, which means that if this is a name that will
eventually be generated then the code we write that references the type will in fact compile.

<p>A simpler alternative would be to defer processing to a later round if we find an
{@code @AutoFactory} class that references undefined types, under the assumption that something
else will generate those types in the meanwhile. However, this would fail if for example
{@code @AutoFactory class Foo} has a constructor parameter of type {@code BarFactory} and
{@code @AutoFactory class Bar} has a constructor parameter of type {@code FooFactory}. We did
in fact find instances of this in Google's source base.

<p>If the type has type annotations then include those in the returned {@link TypeName}.
factory/src/main/java/com/google/auto/factory/processor/FactoryWriter.java