From Chris' review: use cast instead of dyn_cast with an assert.