PsiMethod (PsiMethod @NotNull [] methods, @NotNull List<ReflectiveType> argumentTypes) { int mismatchCount = Integer.MAX_VALUE; PsiMethod bestGuess = null; for (PsiMethod method : methods) { final int match = matchMethodArguments(method, argumentTypes); if (match == 0) { return method; } if (match < 0) { continue; } if (mismatchCount > match) { mismatchCount = match; bestGuess = method; } } return bestGuess; }