import Outputable
import Maybes ( isNothing, catMaybes, mapCatMaybes, seqMaybe )
import SrcLoc ( noSrcLoc, Located(..), mkGeneralSrcSpan,
- unLoc, noLoc, srcLocSpan, SrcSpan )
+ unLoc, noLoc, srcLocSpan, combineSrcSpans, SrcSpan )
import BasicTypes ( DeprecTxt )
import ListSetOps ( removeDups )
import Util ( sortLe, notNull, isSingleton )
(dependent_mods, dependent_pkgs)
| isHomeModule imp_mod
= -- Imported module is from the home package
- -- Take its dependent modules and
- -- (a) remove this_mod (might be there as a hi-boot)
- -- (b) add imp_mod itself
+ -- Take its dependent modules and add imp_mod itself
-- Take its dependent packages unchanged
+ -- NB: (dep_mods deps) might include a hi-boot file for the module being
+ -- compiled, CM. Do *not* filter this out (as we used to), because when
+ -- we've finished dealing with the direct imports we want to know if any
+ -- of them depended on CM.hi-boot, in which case we should do the hi-boot
+ -- consistency check. See LoadIface.loadHiBootInterface
((imp_mod_name, want_boot) : dep_mods deps, dep_pkgs deps)
| otherwise
[] -> pprPanic "exportClashErr" (ppr name)
addDupDeclErr :: [Name] -> TcRn ()
-addDupDeclErr (n:ns)
- = addErrAt (srcLocSpan (nameSrcLoc n)) $
- vcat [ptext SLIT("Multiple declarations of") <+> quotes (ppr n),
- nest 2 (ptext SLIT("other declarations at:")),
- nest 4 (vcat (map ppr sorted_locs))]
+addDupDeclErr names
+ = addErrAt big_loc $
+ vcat [ptext SLIT("Multiple declarations of") <+> quotes (ppr name1),
+ ptext SLIT("Declared at:") <+> vcat (map ppr sorted_locs)]
where
- sorted_locs = sortLe occ'ed_before (map nameSrcLoc ns)
- occ'ed_before a b = case compare a b of
- LT -> True
- EQ -> True
- GT -> False
+ locs = map nameSrcLoc names
+ big_loc = foldr1 combineSrcSpans (map srcLocSpan locs)
+ name1 = head names
+ sorted_locs = sortLe (<=) (sortLe (<=) locs)
dupExportWarn occ_name ie1 ie2
= hsep [quotes (ppr occ_name),