private void addArg(Expression arg) {
    if (arg instanceof NotExpression) {
      NotExpression not = (NotExpression)arg;
      addArg(not.getExpression());
      call(resources.getAstNodeCache().InteractionBuilder_NegateLastArg);
      return;
    }

    if (arg instanceof CastExpression) {
      CastExpression cast = (CastExpression)arg;

      if (cast.getExpression() instanceof ListExpression) {
        // keep casting expression so that `[] as Set` will still be correctly cast
        call(resources.getAstNodeCache().InteractionBuilder_AddEqualArg, arg);
      } else {
        addArg(cast.getExpression());
      }

      call(resources.getAstNodeCache().InteractionBuilder_TypeLastArg, new ClassExpression(cast.getType()));
      return;
    }

    if (arg instanceof ClosureExpression) {
      call(resources.getAstNodeCache().InteractionBuilder_AddCodeArg, arg);
      return;
    }

    call(resources.getAstNodeCache().InteractionBuilder_AddEqualArg, arg);
  }
If the given statement is a valid interaction definition, returns the rewritten statement.
If the given statement is not an interaction definition, returns null.
If the given statement is an invalid interaction definition, records a compile error
and returns null.
spock-core/src/main/java/org/spockframework/compiler/InteractionRewriter.java