Don't just pick the back edges ({-# SOURCE #-} imports) when
collecting the list of imports for module initialisation. It's
entirely possible that a module is only reachable from Main via {-#
SOURCE #-} imports.
getIfacesRn `thenRn` \ ifaces ->
let
direct_import_mods :: [Module]
getIfacesRn `thenRn` \ ifaces ->
let
direct_import_mods :: [Module]
- direct_import_mods = [m | (_, _, Just (m, _, _, _, ImportByUser, _))
- <- eltsFM (iImpModInfo ifaces)]
- -- Pick just the non-back-edge imports
- -- (Back edges are ImportByUserSource)
+ direct_import_mods = [m | (_, _, Just (m, _, _, _, imp, _))
+ <- eltsFM (iImpModInfo ifaces), user_import imp]
+
+ -- *don't* just pick the forward edges. It's entirely possible
+ -- that a module is only reachable via back edges.
+ user_import ImportByUser = True
+ user_import ImportByUserSource = True
+ user_import _ = False
this_module = mkThisModule mod_name
this_module = mkThisModule mod_name