Program: 91192
Project: 91192
Buggy source:
@Override public boolean filter(Executable elem) throws Exception {
  Executable equivalentMethod=null;
  sd=(SymbolType)expression.getScope().getSymbolData();
  if (sd == null) {
    expression.getScope().accept(typeResolver,ctx);
    sd=(SymbolType)expression.getScope().getSymbolData();
    if (!expression.getIdentifier().equals("String_Node_Str")) {
      if (methodsArray == null) {
        Set<Method> methods=MethodInspector.getVisibleMethods(sd.getClazz(),thisClass);
        methodsArray=new Method[methods.size()];
        methods.toArray(methodsArray);
        ExecutableSorter<Method> sorter=new ExecutableSorter<Method>();
        List<Method> sortedMethods=sorter.sort(methodsArray,null);
        sortedMethods.toArray(methodsArray);
      }
      ArrayFilter<Method> filter=new ArrayFilter<Method>(methodsArray);
      filter.appendPredicate(new MethodsByNamePredicate(expression.getIdentifier()));
      methodCallCandidates=filter.filter();
    }
  }
  boolean found=false;
  if (!expression.getIdentifier().equals("String_Node_Str")) {
    Iterator<Method> it=methodCallCandidates.iterator();
    while (it.hasNext() && !found) {
      Method md=it.next();
      int mdParameterCount=md.getParameterTypes().length;
      int elemParameterCount=elem.getParameterTypes().length;
      Map<String,SymbolType> typeMapping=getTypeMapping();
      FunctionalGenericsBuilder<MethodReferenceExpr> builder=new FunctionalGenericsBuilder<MethodReferenceExpr>(md,typeResolver,typeMapping);
      builder.build(expression);
      SymbolType[] args=builder.getArgs();
      if (!Modifier.isStatic(md.getModifiers())) {
        if (mdParameterCount == elemParameterCount - 1) {
          Type[] genericParameterTypes=elem.getGenericParameterTypes();
          SymbolType[] genericArgs=new SymbolType[genericParameterTypes.length];
          boolean allAreGenerics=true;
          for (int i=0; i < genericParameterTypes.length && allAreGenerics; i++) {
            if (genericParameterTypes[i] instanceof TypeVariable<?>) {
              TypeVariable<?> td=(TypeVariable<?>)genericParameterTypes[i];
              genericArgs[i]=typeMapping.get(td.getName());
              allAreGenerics=genericArgs[i] != null;
            }
 else {
              allAreGenerics=false;
            }
          }
          if (allAreGenerics) {
            setTypeArgs(genericArgs);
            found=super.filter(elem);
          }
 else {
            SymbolType[] staticArgs=new SymbolType[args.length + 1];
            for (int i=0; i < args.length; i++) {
              staticArgs[i + 1]=args[i];
            }
            staticArgs[0]=(SymbolType)sd;
            args=staticArgs;
            setTypeArgs(args);
            found=super.filter(elem);
          }
        }
 else {
          Expression scope=expression.getScope();
          SymbolType stype=(SymbolType)scope.getSymbolData();
          boolean isField=stype.getField() != null;
          boolean isVariable=false;
          if (!isField) {
            String name=scope.toString();
            isVariable=(symTable.findSymbol(name,ReferenceType.VARIABLE) != null);
          }
          if ((isField || isVariable) && mdParameterCount == elemParameterCount) {
            setTypeArgs(args);
            found=super.filter(elem);
          }
        }
      }
 else       if (mdParameterCount == elemParameterCount) {
        setTypeArgs(args);
        found=super.filter(elem);
      }
      if (found) {
        equivalentMethod=md;
      }
    }
  }
 else {
    Constructor<?>[] constructors=sd.getClazz().getDeclaredConstructors();
    for (int i=0; i < constructors.length && !found; i++) {
      FunctionalGenericsBuilder<MethodReferenceExpr> builder=new FunctionalGenericsBuilder<MethodReferenceExpr>(constructors[i],typeResolver,getTypeMapping());
      builder.build(expression);
      SymbolType[] args=builder.getArgs();
      setTypeArgs(args);
      found=super.filter(elem);
      if (found) {
        equivalentMethod=constructors[i];
      }
    }
  }
  if (found && elem instanceof Method) {
    Map<String,SymbolType> mapping=getTypeMapping();
    SymbolType realResultType=null;
    if (equivalentMethod instanceof Method) {
      realResultType=SymbolType.valueOf((Method)equivalentMethod,mapping);
      java.lang.reflect.Type genericReturnType=((Method)elem).getGenericReturnType();
      resolveTypeMapping(genericReturnType,realResultType,mapping);
    }
    realResultType=SymbolType.valueOf(elem.getDeclaringClass(),mapping);
    expression.setSymbolData(realResultType);
    SymbolType st=SymbolType.valueOf((Method)elem,mapping);
    expression.setReferencedMethodSymbolData(st);
    expression.setReferencedArgsSymbolData(getTypeArgs());
  }
  return found;
}

Fixed version (ground truth):
@Override public boolean filter(Executable elem) throws Exception {
  Executable equivalentMethod=null;
  sd=(SymbolType)expression.getScope().getSymbolData();
  if (sd == null) {
    expression.getScope().accept(typeResolver,ctx);
    sd=(SymbolType)expression.getScope().getSymbolData();
    if (!expression.getIdentifier().equals("String_Node_Str")) {
      if (methodsArray == null) {
        Set<Method> methods=MethodInspector.getVisibleMethods(sd.getClazz(),thisClass);
        methodsArray=new Method[methods.size()];
        methods.toArray(methodsArray);
        ExecutableSorter<Method> sorter=new ExecutableSorter<Method>();
        List<Method> sortedMethods=sorter.sort(methodsArray,null);
        sortedMethods.toArray(methodsArray);
      }
      ArrayFilter<Method> filter=new ArrayFilter<Method>(methodsArray);
      filter.appendPredicate(new MethodsByNamePredicate(expression.getIdentifier()));
      methodCallCandidates=filter.filter();
    }
  }
  boolean found=false;
  if (!expression.getIdentifier().equals("String_Node_Str")) {
    Iterator<Method> it=methodCallCandidates.iterator();
    while (it.hasNext() && !found) {
      Method md=it.next();
      int mdParameterCount=md.getParameterTypes().length;
      int elemParameterCount=elem.getParameterTypes().length;
      Map<String,SymbolType> typeMapping=getTypeMapping();
      FunctionalGenericsBuilder<MethodReferenceExpr> builder=new FunctionalGenericsBuilder<MethodReferenceExpr>(md,typeResolver,typeMapping);
      builder.build(expression);
      SymbolType[] args=builder.getArgs();
      if (!Modifier.isStatic(md.getModifiers())) {
        if (mdParameterCount == elemParameterCount - 1) {
          Type[] genericParameterTypes=elem.getGenericParameterTypes();
          SymbolType[] genericArgs=new SymbolType[genericParameterTypes.length];
          boolean allAreGenerics=true;
          for (int i=0; i < genericParameterTypes.length && allAreGenerics; i++) {
            if (genericParameterTypes[i] instanceof TypeVariable<?>) {
              TypeVariable<?> td=(TypeVariable<?>)genericParameterTypes[i];
              genericArgs[i]=typeMapping.get(td.getName());
              allAreGenerics=genericArgs[i] != null;
            }
 else {
              allAreGenerics=false;
            }
          }
          if (allAreGenerics) {
            setTypeArgs(genericArgs);
            found=super.filter(elem);
          }
 else {
            SymbolType[] staticArgs=new SymbolType[args.length + 1];
            for (int i=0; i < args.length; i++) {
              staticArgs[i + 1]=args[i];
            }
            staticArgs[0]=(SymbolType)sd;
            args=staticArgs;
            setTypeArgs(args);
            found=super.filter(elem);
          }
        }
 else {
          Expression scope=expression.getScope();
          SymbolType stype=(SymbolType)scope.getSymbolData();
          boolean isField=stype.getField() != null;
          boolean isVariable=false;
          boolean isSuper=scope instanceof SuperExpr;
          if (!isField && !isSuper) {
            String name=scope.toString();
            isVariable=(symTable.findSymbol(name,ReferenceType.VARIABLE) != null);
          }
          if ((isField || isVariable || isSuper) && mdParameterCount == elemParameterCount) {
            setTypeArgs(args);
            found=super.filter(elem);
          }
        }
      }
 else       if (mdParameterCount == elemParameterCount) {
        setTypeArgs(args);
        found=super.filter(elem);
      }
      if (found) {
        equivalentMethod=md;
      }
    }
  }
 else {
    Constructor<?>[] constructors=sd.getClazz().getDeclaredConstructors();
    for (int i=0; i < constructors.length && !found; i++) {
      FunctionalGenericsBuilder<MethodReferenceExpr> builder=new FunctionalGenericsBuilder<MethodReferenceExpr>(constructors[i],typeResolver,getTypeMapping());
      builder.build(expression);
      SymbolType[] args=builder.getArgs();
      setTypeArgs(args);
      found=super.filter(elem);
      if (found) {
        equivalentMethod=constructors[i];
      }
    }
  }
  if (found && elem instanceof Method) {
    Map<String,SymbolType> mapping=getTypeMapping();
    SymbolType realResultType=null;
    if (equivalentMethod instanceof Method) {
      realResultType=SymbolType.valueOf((Method)equivalentMethod,mapping);
      java.lang.reflect.Type genericReturnType=((Method)elem).getGenericReturnType();
      resolveTypeMapping(genericReturnType,realResultType,mapping);
    }
    realResultType=SymbolType.valueOf(elem.getDeclaringClass(),mapping);
    expression.setSymbolData(realResultType);
    SymbolType st=SymbolType.valueOf((Method)elem,mapping);
    expression.setReferencedMethodSymbolData(st);
    expression.setReferencedArgsSymbolData(getTypeArgs());
  }
  return found;
}