Set<GroovyMethodResult> (Set<GroovyMethodResult> candidates) { if (myArgumentTypes == null) return candidates; Set<GroovyMethodResult> result = new LinkedHashSet<>(); for (GroovyMethodResult candidate : candidates) { if (candidate.getElement().getParameterList().getParametersCount() == myArgumentTypes.length) { result.add(candidate); } } if (!result.isEmpty()) return result; return candidates; }