List<GrSignature> (@NotNull List<? extends GrSignature> signatures) { final List<GrSignature> result = new ArrayList<>(); for (GrSignature signature : signatures) { final GrClosureParameter[] original = signature.getParameters(); final ArrayList<GrClosureParameter> parameters = new ArrayList<>(original.length); for (GrClosureParameter parameter : original) { parameters.add(new GrDelegatingClosureParameter(parameter) { @Override public boolean isOptional() { return false; } @Nullable @Override public GrExpression getDefaultInitializer() { return null; } }); } final int pCount = signature.isVarargs() ? signature.getParameterCount() - 2 : signature.getParameterCount() - 1; for (int i = pCount; i >= 0; i--) { if (original[i].isOptional()) { result.add(new GrImmediateClosureSignatureImpl(parameters.toArray(GrClosureParameter.EMPTY_ARRAY), signature.getReturnType(), signature.isVarargs(), false)); parameters.remove(i); } } result.add(new GrImmediateClosureSignatureImpl(parameters.toArray(GrClosureParameter.EMPTY_ARRAY), signature.getReturnType(), signature.isVarargs(), false)); } return result; }