Use actual class of dep when recreating merged deps

Refs #19182.