Program: 25545
Project: 25545
Buggy source:
private void defineVarsForType(TypeElement type,AutoValueTemplateVars vars,Set<ExecutableElement> methods){
  Types typeUtils=processingEnv.getTypeUtils();
  determineObjectMethodsToGenerate(methods,vars);
  ImmutableSet<ExecutableElement> methodsToImplement=methodsToImplement(type,methods);
  Set<TypeMirror> types=new TypeMirrorSet();
  types.addAll(returnTypesOf(methodsToImplement));
  TypeElement generatedTypeElement=processingEnv.getElementUtils().getTypeElement(Generated.class.getName());
  if (generatedTypeElement != null) {
    types.add(generatedTypeElement.asType());
  }
  TypeMirror javaUtilArrays=getTypeMirror(Arrays.class);
  if (containsArrayType(types)) {
    types.add(javaUtilArrays);
  }
  BuilderSpec builderSpec=new BuilderSpec(type,processingEnv,errorReporter);
  Optional<BuilderSpec.Builder> builder=builderSpec.getBuilder();
  ImmutableSet<ExecutableElement> toBuilderMethods;
  if (builder.isPresent()) {
    toBuilderMethods=builder.get().toBuilderMethods(typeUtils,methodsToImplement);
    types.addAll(builder.get().referencedTypes());
  }
 else {
    toBuilderMethods=ImmutableSet.of();
  }
  vars.toBuilderMethods=FluentIterable.from(toBuilderMethods).transform(SimpleNameFunction.INSTANCE).toList();
  Set<ExecutableElement> propertyMethods=Sets.difference(methodsToImplement,toBuilderMethods);
  types.addAll(allMethodAnnotationTypes(propertyMethods));
  String pkg=TypeSimplifier.packageNameOf(type);
  TypeSimplifier typeSimplifier=new TypeSimplifier(typeUtils,pkg,types,type.asType());
  vars.imports=typeSimplifier.typesToImport();
  vars.generated=generatedTypeElement == null ? "String_Node_Str" : typeSimplifier.simplify(generatedTypeElement.asType());
  vars.arrays=typeSimplifier.simplify(javaUtilArrays);
  ImmutableBiMap<ExecutableElement,String> methodToPropertyName=propertyNameToMethodMap(propertyMethods).inverse();
  Map<ExecutableElement,String> methodToIdentifier=Maps.newLinkedHashMap(methodToPropertyName);
  fixReservedIdentifiers(methodToIdentifier);
  List<Property> props=new ArrayList<Property>();
  for (  ExecutableElement method : propertyMethods) {
    String propertyType=typeSimplifier.simplify(method.getReturnType());
    String propertyName=methodToPropertyName.get(method);
    String identifier=methodToIdentifier.get(method);
    props.add(new Property(propertyName,identifier,method,propertyType,typeSimplifier));
  }
  eclipseHack().reorderProperties(props);
  vars.props=ImmutableSet.copyOf(props);
  vars.serialVersionUID=getSerialVersionUID(type);
  vars.formalTypes=typeSimplifier.formalTypeParametersString(type);
  vars.actualTypes=TypeSimplifier.actualTypeParametersString(type);
  vars.wildcardTypes=wildcardTypeParametersString(type);
  if (builder.isPresent()) {
    builder.get().defineVars(vars,typeSimplifier,methodToPropertyName);
  }
}

Fixed version (ground truth):
private void defineVarsForType(TypeElement type,AutoValueTemplateVars vars,Set<ExecutableElement> methods){
  Types typeUtils=processingEnv.getTypeUtils();
  determineObjectMethodsToGenerate(methods,vars);
  ImmutableSet<ExecutableElement> methodsToImplement=methodsToImplement(type,methods);
  Set<TypeMirror> types=new TypeMirrorSet();
  types.addAll(returnTypesOf(methodsToImplement));
  TypeElement generatedTypeElement=processingEnv.getElementUtils().getTypeElement(Generated.class.getName());
  if (generatedTypeElement != null) {
    types.add(generatedTypeElement.asType());
  }
  TypeMirror javaUtilArrays=getTypeMirror(Arrays.class);
  if (containsArrayType(types)) {
    types.add(javaUtilArrays);
  }
  BuilderSpec builderSpec=new BuilderSpec(type,processingEnv,errorReporter);
  Optional<BuilderSpec.Builder> builder=builderSpec.getBuilder();
  ImmutableSet<ExecutableElement> toBuilderMethods;
  if (builder.isPresent()) {
    toBuilderMethods=builder.get().toBuilderMethods(typeUtils,methodsToImplement);
    types.addAll(builder.get().referencedTypes());
  }
 else {
    toBuilderMethods=ImmutableSet.of();
  }
  vars.toBuilderMethods=FluentIterable.from(toBuilderMethods).transform(SimpleNameFunction.INSTANCE).toList();
  Set<ExecutableElement> propertyMethods=Sets.difference(methodsToImplement,toBuilderMethods);
  types.addAll(allMethodAnnotationTypes(propertyMethods));
  String pkg=TypeSimplifier.packageNameOf(type);
  TypeSimplifier typeSimplifier=new TypeSimplifier(typeUtils,pkg,types,type.asType());
  vars.imports=typeSimplifier.typesToImport();
  vars.generated=generatedTypeElement == null ? "String_Node_Str" : typeSimplifier.simplify(generatedTypeElement.asType());
  vars.arrays=typeSimplifier.simplify(javaUtilArrays);
  ImmutableBiMap<ExecutableElement,String> methodToPropertyName=propertyNameToMethodMap(propertyMethods).inverse();
  Map<ExecutableElement,String> methodToIdentifier=Maps.newLinkedHashMap(methodToPropertyName);
  fixReservedIdentifiers(methodToIdentifier);
  List<Property> props=new ArrayList<Property>();
  DeclaredType autoValueTypeMirror=MoreTypes.asDeclared(type.asType());
  for (  ExecutableElement method : propertyMethods) {
    TypeMirror returnType=returnTypeAsMemberOf(method,autoValueTypeMirror);
    String propertyType=typeSimplifier.simplify(returnType);
    String propertyName=methodToPropertyName.get(method);
    String identifier=methodToIdentifier.get(method);
    props.add(new Property(propertyName,identifier,method,propertyType,typeSimplifier));
  }
  eclipseHack().reorderProperties(props);
  vars.props=ImmutableSet.copyOf(props);
  vars.serialVersionUID=getSerialVersionUID(type);
  vars.formalTypes=typeSimplifier.formalTypeParametersString(type);
  vars.actualTypes=TypeSimplifier.actualTypeParametersString(type);
  vars.wildcardTypes=wildcardTypeParametersString(type);
  if (builder.isPresent()) {
    builder.get().defineVars(vars,typeSimplifier,methodToPropertyName);
  }
}