diff options
Diffstat (limited to 'compiler/rename')
-rw-r--r-- | compiler/rename/RnNames.hs | 16 | ||||
-rw-r--r-- | compiler/rename/RnSource.hs | 22 |
2 files changed, 18 insertions, 20 deletions
diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs index d469207282..c371d47067 100644 --- a/compiler/rename/RnNames.hs +++ b/compiler/rename/RnNames.hs @@ -222,7 +222,7 @@ rnImportDecl this_mod -- c.f. GHC.findModule, and Trac #9997 Nothing -> True Just (StringLiteral _ pkg_fs) -> pkg_fs == fsLit "this" || - fsToPackageKey pkg_fs == modulePackageKey this_mod)) + fsToUnitId pkg_fs == moduleUnitId this_mod)) (addErr (ptext (sLit "A module cannot import itself:") <+> ppr imp_mod_name)) -- Check for a missing import list (Opt_WarnMissingImportList also @@ -337,7 +337,7 @@ calculateAvails dflags iface mod_safe' want_boot = imp_mod : dep_finsts deps | otherwise = dep_finsts deps - pkg = modulePackageKey (mi_module iface) + pkg = moduleUnitId (mi_module iface) -- Does this import mean we now require our own pkg -- to be trusted? See Note [Trust Own Package] @@ -1601,18 +1601,16 @@ extendImportMap_Field rdr_env (FieldOcc rdr sel) = where lbl = occNameFS (rdrNameOcc rdr) --- For a single used GRE, find all the import decls that brought +-- For each of a list of used GREs, find all the import decls that brought -- it into scope; choose one of them (bestImport), and record -- the RdrName in that import decl's entry in the ImportMap extendImportMap_GRE :: [GlobalRdrElt] -> ImportMap -> ImportMap extendImportMap_GRE gres imp_map - | [gre] <- gres - , GRE { gre_lcl = lcl, gre_imp = imps } <- gre - , not lcl - = add_imp gre (bestImport imps) imp_map - | otherwise - = imp_map + = foldr recordRdrName imp_map nonLocalGREs where + recordRdrName gre m = add_imp gre (bestImport (gre_imp gre)) m + nonLocalGREs = filter (not . gre_lcl) gres + add_imp :: GlobalRdrElt -> ImportSpec -> ImportMap -> ImportMap add_imp gre (ImpSpec { is_decl = imp_decl_spec }) imp_map = Map.insertWith add decl_loc [avail] imp_map diff --git a/compiler/rename/RnSource.hs b/compiler/rename/RnSource.hs index 18eb24dfbf..f89f1b2ceb 100644 --- a/compiler/rename/RnSource.hs +++ b/compiler/rename/RnSource.hs @@ -391,8 +391,8 @@ rnHsForeignDecl (ForeignImport name ty _ spec) ; (ty', fvs) <- rnLHsType (ForeignDeclCtx name) ty -- Mark any PackageTarget style imports as coming from the current package - ; let packageKey = thisPackage $ hsc_dflags topEnv - spec' = patchForeignImport packageKey spec + ; let unitId = thisPackage $ hsc_dflags topEnv + spec' = patchForeignImport unitId spec ; return (ForeignImport name' ty' noForeignImportCoercionYet spec', fvs) } @@ -409,21 +409,21 @@ rnHsForeignDecl (ForeignExport name ty _ spec) -- package, so if they get inlined across a package boundry we'll still -- know where they're from. -- -patchForeignImport :: PackageKey -> ForeignImport -> ForeignImport -patchForeignImport packageKey (CImport cconv safety fs spec src) - = CImport cconv safety fs (patchCImportSpec packageKey spec) src +patchForeignImport :: UnitId -> ForeignImport -> ForeignImport +patchForeignImport unitId (CImport cconv safety fs spec src) + = CImport cconv safety fs (patchCImportSpec unitId spec) src -patchCImportSpec :: PackageKey -> CImportSpec -> CImportSpec -patchCImportSpec packageKey spec +patchCImportSpec :: UnitId -> CImportSpec -> CImportSpec +patchCImportSpec unitId spec = case spec of - CFunction callTarget -> CFunction $ patchCCallTarget packageKey callTarget + CFunction callTarget -> CFunction $ patchCCallTarget unitId callTarget _ -> spec -patchCCallTarget :: PackageKey -> CCallTarget -> CCallTarget -patchCCallTarget packageKey callTarget = +patchCCallTarget :: UnitId -> CCallTarget -> CCallTarget +patchCCallTarget unitId callTarget = case callTarget of StaticTarget src label Nothing isFun - -> StaticTarget src label (Just packageKey) isFun + -> StaticTarget src label (Just unitId) isFun _ -> callTarget {- |