I have a very general idea of how to do it. I'm afraid I won't be able to do it immediately, I'm looking into it. But when there is an update I will definitely check and let you know.
The problem seems to be that the view using the cast is itself depended on (indirectly through another view) by another function a_ext_by_id(), which is using the intermediate view's rowtype as its output type. So that causes the dependency sort to hoist those two views above the function a_ext_by_id(), and now they're ahead of the cast, which is just left at its initial priority-driven location.
I think we can fix this by adjusting the sort priority order as per the attached patch. This fixes this toy test case anyway. Can you check to see if it fixes your real database?
(Note that as given, the patch will only apply to v14 not earlier branches.)