From dd365b1baab08b44e8feb1715ecacf7407628d5c Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 21 Jul 2015 17:16:52 -0700 Subject: Use lookupIfaceTop for loading IfaceDecls. Summary: It's shorter! And then when Backpack overrides lookupIfaceTop everyone will see the right information. Signed-off-by: Edward Z. Yang Test Plan: validate Reviewers: simonpj, austin, bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1090 --- compiler/iface/IfaceEnv.hs | 5 ++++- compiler/iface/LoadIface.hs | 10 ++++------ compiler/iface/TcIface.hs | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) (limited to 'compiler') diff --git a/compiler/iface/IfaceEnv.hs b/compiler/iface/IfaceEnv.hs index 1bd931674f..a822b100e9 100644 --- a/compiler/iface/IfaceEnv.hs +++ b/compiler/iface/IfaceEnv.hs @@ -151,7 +151,10 @@ newImplicitBinder base_name mk_sys_occ ifaceExportNames :: [IfaceExport] -> TcRnIf gbl lcl [AvailInfo] ifaceExportNames exports = return exports -lookupOrig :: Module -> OccName -> TcRnIf a b Name +-- | Look up the 'Name' for a given 'Module' and 'OccName'. +-- Consider alternately using 'lookupIfaceTop' if you're in the 'IfL' monad +-- and 'Module' is simply that of the 'ModIface' you are typechecking. +lookupOrig :: Module -> OccName -> TcRnIf a b Name lookupOrig mod occ = do { -- First ensure that mod and occ are evaluated -- If not, chaos can ensue: diff --git a/compiler/iface/LoadIface.hs b/compiler/iface/LoadIface.hs index ad813578c4..9da1175a5d 100644 --- a/compiler/iface/LoadIface.hs +++ b/compiler/iface/LoadIface.hs @@ -585,20 +585,18 @@ loadDecls :: Bool -> [(Fingerprint, IfaceDecl)] -> IfL [(Name,TyThing)] loadDecls ignore_prags ver_decls - = do { mod <- getIfModule - ; thingss <- mapM (loadDecl ignore_prags mod) ver_decls + = do { thingss <- mapM (loadDecl ignore_prags) ver_decls ; return (concat thingss) } loadDecl :: Bool -- Don't load pragmas into the decl pool - -> Module -> (Fingerprint, IfaceDecl) -> IfL [(Name,TyThing)] -- The list can be poked eagerly, but the -- TyThings are forkM'd thunks -loadDecl ignore_prags mod (_version, decl) +loadDecl ignore_prags (_version, decl) = do { -- Populate the name cache with final versions of all -- the names associated with the decl - main_name <- lookupOrig mod (ifName decl) + main_name <- lookupIfaceTop (ifName decl) -- Typecheck the thing, lazily -- NB. Firstly, the laziness is there in case we never need the @@ -671,7 +669,7 @@ loadDecl ignore_prags mod (_version, decl) Nothing -> pprPanic "loadDecl" (ppr main_name <+> ppr n $$ ppr (decl)) - ; implicit_names <- mapM (lookupOrig mod) (ifaceDeclImplicitBndrs decl) + ; implicit_names <- mapM lookupIfaceTop (ifaceDeclImplicitBndrs decl) -- ; traceIf (text "Loading decl for " <> ppr main_name $$ ppr implicit_names) ; return $ (main_name, thing) : diff --git a/compiler/iface/TcIface.hs b/compiler/iface/TcIface.hs index 9480aec578..a7c340f780 100644 --- a/compiler/iface/TcIface.hs +++ b/compiler/iface/TcIface.hs @@ -736,7 +736,7 @@ tcIfaceVectInfo mod typeEnv (IfaceVectInfo } where vectVarMapping name - = do { vName <- lookupOrig mod (mkLocalisedOccName mod mkVectOcc name) + = do { vName <- lookupIfaceTop (mkLocalisedOccName mod mkVectOcc name) ; var <- forkM (ptext (sLit "vect var") <+> ppr name) $ tcIfaceExtId name ; vVar <- forkM (ptext (sLit "vect vVar [mod =") <+> @@ -764,7 +764,7 @@ tcIfaceVectInfo mod typeEnv (IfaceVectInfo tcIfaceExtId name vectTyConVectMapping vars name - = do { vName <- lookupOrig mod (mkLocalisedOccName mod mkVectTyConOcc name) + = do { vName <- lookupIfaceTop (mkLocalisedOccName mod mkVectTyConOcc name) ; vectTyConMapping vars name vName } -- cgit v1.2.1