private static int calcArity(Parameter[] parameters) {
    int arity = 0;
    boolean stop = false;
    for (Parameter parameter : parameters) {
      assert !stop;

      if (parameter.kind == Parameter.Kind.REQUIRED) {
        arity++;
      } else if (parameter.kind == Parameter.Kind.OPTIONAL) {
        stop = true;
      } else if (parameter.kind == Parameter.Kind.VARARG) {
        stop = true;
      }
    }
    return arity;
  }
private static int calcArity(Parameter[] parameters)