Move debug dynamic_casts into asserts to make them noop in release.