visitor trait rewrite step 3 (of 5).

Follow up to #8539 (step 2 of 5).

(See  #8527, which was step 1 of 5, for the full outline.)

Part of #7081.