private Expression createDefaultValueInitializer(DeclarationExpression expr) {
    TupleExpression tupleExpr = ObjectUtil.asInstance(expr.getLeftExpression(), TupleExpression.class);
    if (tupleExpr == null) {
      return EmptyExpression.INSTANCE;
    }

    assert expr.isMultipleAssignmentDeclaration();

    // initializing to empty list only works when none of the element types is primitive,
    // so create a proper list expression
    ListExpression listExpr = new ListExpression();
    for (Expression elementExpr : tupleExpr.getExpressions()) {
      Variable variable = (Variable) elementExpr;
      listExpr.addExpression(new ConstantExpression(
          ReflectionUtil.getDefaultValue(variable.getOriginType().getTypeClass())));
    }

    return listExpr;
  }
A Spec visitor responsible for most of the rewriting of a Spec's AST.

@author Peter Niederwieser
spock-core/src/main/java/org/spockframework/compiler/SpecRewriter.java