Program: 185977
Project: 185977
Buggy source:
/** 
 * Finds a method with the given name in the declaring type. Will prioritize methods with the same number of arguments, but if multiple methods exist with same name, then will return an arbitrary one.
 * @param name
 * @param declaringType
 * @param methodCallArgumentTypes
 * @param checkSuperInterfaces potentially look through super interfaces for a declaration to this method
 * @return
 */
private AnnotatedNode findMethodDeclaration(String name,ClassNode declaringType,List<ClassNode> methodCallArgumentTypes,boolean checkSuperInterfaces){
  if (checkSuperInterfaces && declaringType.isInterface()) {
    LinkedHashSet<ClassNode> allInterfaces=new LinkedHashSet<ClassNode>();
    VariableScope.findAllInterfaces(declaringType,allInterfaces,true);
    for (    ClassNode interf : allInterfaces) {
      AnnotatedNode candidate=findMethodDeclaration(name,interf,methodCallArgumentTypes,false);
      if (candidate != null) {
        return candidate;
      }
    }
    return null;
  }
  List<MethodNode> maybeMethods=declaringType.getMethods(name);
  if (maybeMethods != null && maybeMethods.size() > 0) {
    if (methodCallArgumentTypes != null && methodCallArgumentTypes.size() >= 0) {
      for (Iterator<MethodNode> iterator=maybeMethods.iterator(); iterator.hasNext(); ) {
        MethodNode maybeMethod=iterator.next();
        Parameter[] parameters=maybeMethod.getParameters();
        if ((parameters == null || parameters.length == 0) && methodCallArgumentTypes.size() == 0) {
          return maybeMethod.getOriginal();
        }
        if (parameters != null && parameters.length == methodCallArgumentTypes.size()) {
          boolean found=true;
          boolean exactMatchFound=true;
          for (int i=0; i < parameters.length; i++) {
            if (!methodCallArgumentTypes.get(i).equals(parameters[i].getType())) {
              exactMatchFound=false;
            }
            if (parameters[i].getType().isInterface()) {
              if (!methodCallArgumentTypes.get(i).declaresInterface(parameters[i].getType())) {
                found=false;
                break;
              }
            }
 else {
              if (!methodCallArgumentTypes.get(i).isDerivedFrom(parameters[i].getType())) {
                found=false;
                break;
              }
            }
          }
          if (exactMatchFound) {
            return maybeMethod.getOriginal();
          }
          if (!found) {
            iterator.remove();
          }
        }
 else {
          iterator.remove();
        }
      }
    }
    return maybeMethods.get(0);
  }
  if (methodCallArgumentTypes == null) {
    return AccessorSupport.findAccessorMethodForPropertyName(name,declaringType,false);
  }
 else {
    return null;
  }
}

Fixed version (ground truth):
/** 
 * Finds a method with the given name in the declaring type. Will prioritize methods with the same number of arguments, but if multiple methods exist with same name, then will return an arbitrary one.
 * @param name
 * @param declaringType
 * @param methodCallArgumentTypes
 * @param checkSuperInterfaces potentially look through super interfaces for a declaration to this method
 * @return
 */
private AnnotatedNode findMethodDeclaration(String name,ClassNode declaringType,List<ClassNode> methodCallArgumentTypes,boolean checkSuperInterfaces){
  if (checkSuperInterfaces && declaringType.isInterface()) {
    LinkedHashSet<ClassNode> allInterfaces=new LinkedHashSet<ClassNode>();
    VariableScope.findAllInterfaces(declaringType,allInterfaces,true);
    for (    ClassNode interf : allInterfaces) {
      AnnotatedNode candidate=findMethodDeclaration(name,interf,methodCallArgumentTypes,false);
      if (candidate != null) {
        return candidate;
      }
    }
    return null;
  }
  List<MethodNode> maybeMethods=declaringType.getMethods(name);
  if (maybeMethods != null && maybeMethods.size() > 0) {
    if (methodCallArgumentTypes != null && methodCallArgumentTypes.size() >= 0) {
      for (Iterator<MethodNode> iterator=maybeMethods.iterator(); iterator.hasNext(); ) {
        MethodNode maybeMethod=iterator.next();
        Parameter[] parameters=maybeMethod.getParameters();
        if ((parameters == null || parameters.length == 0) && methodCallArgumentTypes.size() == 0) {
          return maybeMethod.getOriginal();
        }
        if (parameters != null && parameters.length == methodCallArgumentTypes.size()) {
          boolean found=true;
          boolean exactMatchFound=true;
          for (int i=0; i < parameters.length; i++) {
            if (!methodCallArgumentTypes.get(i).equals(parameters[i].getType())) {
              exactMatchFound=false;
            }
            if (parameters[i].getType().isInterface()) {
              if (!methodCallArgumentTypes.get(i).declaresInterface(parameters[i].getType())) {
                found=false;
                break;
              }
            }
 else {
              if (!methodCallArgumentTypes.get(i).isDerivedFrom(parameters[i].getType())) {
                found=false;
                break;
              }
            }
          }
          if (exactMatchFound) {
            return maybeMethod.getOriginal();
          }
          if (!found) {
            iterator.remove();
          }
        }
 else {
          iterator.remove();
        }
      }
    }
    return maybeMethods.size() > 0 ? maybeMethods.get(0) : null;
  }
  if (methodCallArgumentTypes == null) {
    return AccessorSupport.findAccessorMethodForPropertyName(name,declaringType,false);
  }
 else {
    return null;
  }
}