Check foreign imports using the GHC stage restriction
GHC was applying the stage restriction to top-level functions, class methods,
and other sorts of identifiers, but it was not applying them to foreign
imports. The reason is because tcTopSrcDecls
was not populating thr
tcl_th_bndrs
of the TcLclEnv
with foreign import names, so the GHC stage
restriction would skip over any foreign import names. This adds the necessary
plumbing to ensure that the tcl_th_bndrs
cover foreign imports as well,
thereby ensuring that the GHC stage restriction check applies to them as well.
Fixes #25189.