boolean (@NotNull List<? extends CandidateInfo> conflicts, final int argumentsCount, Map<MethodCandidateInfo, PsiSubstitutor> map, boolean ignoreIfStaticsProblem) { boolean atLeastOneMatch = false; IntList unmatchedIndices = null; for (int i = 0; i < conflicts.size(); i++) { ProgressManager.checkCanceled(); CandidateInfo info = conflicts.get(i); if (ignoreIfStaticsProblem && !info.isStaticsScopeCorrect()) return true; if (!(info instanceof MethodCandidateInfo)) continue; PsiMethod method = ((MethodCandidateInfo)info).getElement(); final int parametersCount = method.getParameterList().getParametersCount(); boolean isVarargs = (myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) ? ((MethodCandidateInfo)info).isVarargs() : method.isVarArgs()) && parametersCount - 1 <= argumentsCount; if (isVarargs || parametersCount == argumentsCount) { // remove all unmatched before if (unmatchedIndices != null) { for (int u=unmatchedIndices.size()-1; u>=0; u--) { int index = unmatchedIndices.getInt(u); //ensure super method with varargs won't win over non-vararg override if (ignoreIfStaticsProblem && isVarargs) { MethodCandidateInfo candidateInfo = (MethodCandidateInfo)conflicts.get(index); PsiMethod candidateToRemove = candidateInfo.getElement(); if (candidateToRemove != method) { PsiSubstitutor candidateToRemoveSubst = map.get(candidateInfo); PsiSubstitutor substitutor = map.get(info); if (MethodSignatureUtil.isSubsignature(candidateToRemove.getSignature(candidateToRemoveSubst), method.getSignature(substitutor))) { continue; } } } conflicts.remove(index); i--; } unmatchedIndices = null; } atLeastOneMatch = true; } else if (atLeastOneMatch) { conflicts.remove(i); i--; } else { if (unmatchedIndices == null) unmatchedIndices = new IntArrayList(conflicts.size()-i); unmatchedIndices.add(i); } } return atLeastOneMatch; }