- do_avail mod (Avail n) = do { n' <- lookupOrig mod n;
- ; return (Avail n') }
- do_avail mod (AvailTC n ns) = do { n' <- lookupOrig mod n
- ; ns' <- mappM (lookupImplicitOrig n') ns
- ; return (AvailTC n' ns') }
- -- Note the lookupImplicitOrig. It ensures that the subordinate names
- -- record their parent; and that in turn ensures that the GlobalRdrEnv
- -- has the correct parent for all the names in its range.
- -- For imported things, we only suck in the binding site later, if ever.
+ do_avail mod_nm (Avail n) = do { n' <- lookupOrig mod_nm n;
+ ; return (Avail n') }
+ do_avail mod_nm (AvailTC n ns) = do { n' <- lookupOrig mod_nm n
+ ; ns' <- mappM (lookup_sub n') ns
+ ; return (AvailTC n' ns') }
+ where
+ mod = mkPackageModule mod_nm -- Not necessarily right yet
+ lookup_sub parent occ = newGlobalBinder mod occ (Just parent) noSrcLoc
+ -- Hack alert! Notice the newGlobalBinder. It ensures that the subordinate
+ -- names record their parent; and that in turn ensures that the GlobalRdrEnv
+ -- has the correct parent for all the names in its range.
+ -- For imported things, we only suck in the binding site later, if ever.
+ -- Reason for all this:
+ -- Suppose module M exports type A.T, and constructor A.MkT
+ -- Then, we know that A.MkT is a subordinate name of A.T,
+ -- even though we aren't at the binding site of A.T
+ -- And it's important, because we may simply re-export A.T
+ -- without ever sucking in the declaration itself.