[Backport maintenance/4.0.x] Fix crash when a variable annotation is used as `if` test expression (#10729)

Fix crash when a variable annotation is used as `if` test expression (#10714)

Fix crash for ``consider-using-assignment-expr``.

(cherry picked from commit 926529bb3288402c7ccc96a9f5bd7ca85cf38390)

Co-authored-by: Zen Lee <53538590+zenlyj@users.noreply.github.com>
3 files changed