Emit correct code for apply