public static Expression toArgumentArray(List<Expression> argList, IRewriteResources resources) {
    List<Expression> normalArgs = new ArrayList<>();
    List<Expression> spreadArgs = new ArrayList<>();
    List<Expression> spreadPositions = new ArrayList<>();

    for (int i = 0; i < argList.size(); i++) {
      Expression arg = argList.get(i);
      if (arg instanceof SpreadExpression) {
        spreadArgs.add(((SpreadExpression) arg).getExpression());
        spreadPositions.add(primitiveConstExpression(i));
      } else {
        normalArgs.add(arg);
      }
    }

    if (spreadArgs.isEmpty())
      return new ArrayExpression(ClassHelper.OBJECT_TYPE, argList);

    AstNodeCache astNodeCache = resources.getAstNodeCache();
    return createDirectMethodCall(
      new ClassExpression(astNodeCache.SpockRuntime),
      astNodeCache.SpockRuntime_DespreadList,
      new ArgumentListExpression(
        new ArrayExpression(ClassHelper.OBJECT_TYPE, normalArgs),
        new ArrayExpression(ClassHelper.OBJECT_TYPE, spreadArgs),
        new ArrayExpression(ClassHelper.int_TYPE, spreadPositions)
      ));
  }
Turns an argument list obtained from AstUtil.getArguments() into an Object[] array
suitable to be passed to InvokerHelper or SpockRuntime. The main challenge is
to handle SpreadExpression's correctly.
spock-core/src/main/java/org/spockframework/compiler/AstUtil.java