Program: 91160
Project: 91160
Buggy source:
/** 
 * @param overriddenMethods if != null add all methods to collection otherwise return on first match
 * @return true if method found
 */
private static boolean collectOverriddenMethods(MethodDeclaration md,List<Method> overriddenMethods){
  final MethodSymbolData sdata=md.getSymbolData();
  if (sdata == null || isStatic(sdata.getMethod()) || isPrivate(sdata.getMethod())) {
    return false;
  }
 else {
    boolean result=false;
    final Class<?> declaringClass=sdata.getMethod().getDeclaringClass();
    final Class<?> parentClass=declaringClass.getSuperclass();
    final Class<?>[] interfaces=declaringClass.getInterfaces();
    if (parentClass != null || interfaces.length > 0) {
      final SymbolData[] args=getParameterSymbolData(md);
      List<Class<?>> scopesToCheck=new LinkedList<Class<?>>();
      if (parentClass != null) {
        scopesToCheck.add(parentClass);
      }
      for (int i=0; i < interfaces.length; i++) {
        scopesToCheck.add(interfaces[i]);
      }
      final Iterator<Class<?>> it=scopesToCheck.iterator();
      while (it.hasNext() && !result) {
        final Class<?> clazzToAnalyze=it.next();
        final Method foundMethod=MethodInspector.findMethod(clazzToAnalyze,args,md.getName());
        if (foundMethod != null) {
          if (foundMethod.getDeclaringClass().isAssignableFrom(clazzToAnalyze)) {
            List<Type> types=ClassInspector.getInterfaceOrSuperclassImplementations(declaringClass,clazzToAnalyze);
            Class<?> returnType=null;
            if (types != null && !types.isEmpty()) {
              if (types.get(0) instanceof Class) {
                returnType=(Class<?>)types.get(0);
              }
            }
            if (matchesReturnAndParameters(foundMethod,returnType,args)) {
              if (overriddenMethods != null) {
                overriddenMethods.add(foundMethod);
              }
 else {
                result=true;
              }
            }
          }
        }
      }
    }
    return overriddenMethods != null ? !overriddenMethods.isEmpty() : result;
  }
}

Fixed version (ground truth):
/** 
 * Returns if any of the overriddenMethods overrides an specific method declaration.
 * @param md the method declaration
 * @param overriddenMethods if != null add all methods to collection otherwise return on first match
 * @return true if at least one method of the overriddenMethods overrides an specific method declaration.
 */
private static boolean collectOverriddenMethods(MethodDeclaration md,List<Method> overriddenMethods){
  final MethodSymbolData sdata=md.getSymbolData();
  if (sdata == null || isStatic(sdata.getMethod()) || isPrivate(sdata.getMethod())) {
    return false;
  }
 else {
    boolean result=false;
    final Class<?> declaringClass=sdata.getMethod().getDeclaringClass();
    final Class<?> parentClass=declaringClass.getSuperclass();
    final Class<?>[] interfaces=declaringClass.getInterfaces();
    if (parentClass != null || interfaces.length > 0) {
      final SymbolData[] args=getParameterSymbolData(md);
      List<Class<?>> scopesToCheck=new LinkedList<Class<?>>();
      if (parentClass != null) {
        scopesToCheck.add(parentClass);
      }
      for (int i=0; i < interfaces.length; i++) {
        scopesToCheck.add(interfaces[i]);
      }
      final Iterator<Class<?>> it=scopesToCheck.iterator();
      while (it.hasNext() && !result) {
        final Class<?> clazzToAnalyze=it.next();
        final Method foundMethod=MethodInspector.findMethod(clazzToAnalyze,args,md.getName());
        if (foundMethod != null) {
          if (foundMethod.getDeclaringClass().isAssignableFrom(clazzToAnalyze)) {
            List<Type> types=ClassInspector.getInterfaceOrSuperclassImplementations(declaringClass,clazzToAnalyze);
            Class<?> returnType=null;
            if (types != null && !types.isEmpty()) {
              if (types.get(0) instanceof Class) {
                returnType=(Class<?>)types.get(0);
              }
            }
            if (matchesReturnAndParameters(foundMethod,returnType,args)) {
              if (overriddenMethods != null) {
                overriddenMethods.add(foundMethod);
              }
 else {
                result=true;
              }
            }
          }
        }
      }
    }
    return overriddenMethods != null ? !overriddenMethods.isEmpty() : result;
  }
}