[Diagnostics] Do more checking before recording `force downcast` fix
Solver should do more checking upfront before recording
`force downcast` fix, to make sure that it's indeed always
applicable when recorded, otherwise it would be possible
to misdiagnose or omit diagnostics in certain situations.
Resolves: rdar://problem/65254452
(cherry picked from commit d89c096af75524dd5e1cf7bc2d1d0fb43997db9c)