Allow closures into/through genexps

The issue was that if we transformed the AST nodes corresponding to scopes,
we wouldn't be able to match the initial analysis with the subsequent queries
to the transformed AST nodes.

We had run into that before, but worked around it by just modifying the AST
nodes in place.  For generator expressions that wasn't a possibility,
so now we explicitly registers when we replace scope-related AST nodes.