diff options
author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-06-03 15:29:00 -0700 |
---|---|---|
committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2015-06-11 15:20:48 -0700 |
commit | 28e04de37151f05c35377ec74ac214d0cfa2f521 (patch) | |
tree | 9ec1e8b2f320136c7dd72943ed033477464c0185 | |
parent | 23582b0c16bb147dad6bd7dee98686a8b61eacea (diff) | |
download | haskell-28e04de37151f05c35377ec74ac214d0cfa2f521.tar.gz |
Remove redundant tcg_visible_orphan_mods, it is recorded in imp_orphs.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, austin
Subscribers: bgamari, thomie
Differential Revision: https://phabricator.haskell.org/D947
-rw-r--r-- | compiler/typecheck/Inst.hs | 2 | ||||
-rw-r--r-- | compiler/typecheck/TcEnv.hs | 2 | ||||
-rw-r--r-- | compiler/typecheck/TcRnDriver.hs | 17 | ||||
-rw-r--r-- | compiler/typecheck/TcRnMonad.hs | 1 | ||||
-rw-r--r-- | compiler/typecheck/TcRnTypes.hs | 11 |
5 files changed, 15 insertions, 18 deletions
diff --git a/compiler/typecheck/Inst.hs b/compiler/typecheck/Inst.hs index c1a1c5a98b..07d7e0a3b3 100644 --- a/compiler/typecheck/Inst.hs +++ b/compiler/typecheck/Inst.hs @@ -514,7 +514,7 @@ addLocalInst (home_ie, my_insts) ispec | otherwise = eps_inst_env eps inst_envs = InstEnvs { ie_global = global_ie , ie_local = home_ie' - , ie_visible = tcg_visible_orphan_mods tcg_env } + , ie_visible = tcVisibleOrphanMods tcg_env } (matches, _, _) = lookupInstEnv False inst_envs cls tys dups = filter (identicalClsInstHead ispec) (map fst matches) diff --git a/compiler/typecheck/TcEnv.hs b/compiler/typecheck/TcEnv.hs index 6337b3d88f..8db9f263ae 100644 --- a/compiler/typecheck/TcEnv.hs +++ b/compiler/typecheck/TcEnv.hs @@ -232,7 +232,7 @@ tcGetInstEnvs = do { eps <- getEps ; env <- getGblEnv ; return (InstEnvs { ie_global = eps_inst_env eps , ie_local = tcg_inst_env env - , ie_visible = tcg_visible_orphan_mods env }) } + , ie_visible = tcVisibleOrphanMods env }) } instance MonadThings (IOEnv (Env TcGblEnv TcLclEnv)) where lookupThing = tcLookupGlobal diff --git a/compiler/typecheck/TcRnDriver.hs b/compiler/typecheck/TcRnDriver.hs index 16c8d37ee4..585d3b3309 100644 --- a/compiler/typecheck/TcRnDriver.hs +++ b/compiler/typecheck/TcRnDriver.hs @@ -418,9 +418,6 @@ tcRnImports hsc_env import_decls tcg_rdr_env = tcg_rdr_env gbl `plusGlobalRdrEnv` rdr_env, tcg_imports = tcg_imports gbl `plusImportAvails` imports, tcg_rn_imports = rn_imports, - tcg_visible_orphan_mods = foldl extendModuleSet - (tcg_visible_orphan_mods gbl) - (imp_orphs imports), tcg_inst_env = extendInstEnvList (tcg_inst_env gbl) home_insts, tcg_fam_inst_env = extendFamInstEnvList (tcg_fam_inst_env gbl) home_fam_insts, @@ -1405,14 +1402,18 @@ runTcInteractive hsc_env thing_inside vcat (map ppr [ local_gres | gres <- occEnvElts (ic_rn_gbl_env icxt) , let local_gres = filter isLocalGRE gres , not (null local_gres) ]) ] + ; let getOrphans m = fmap (concatMap (\iface -> mi_module iface : dep_orphs (mi_deps iface))) (loadSrcInterface (text "runTcInteractive") m False Nothing) - ; ic_visible_mods <- fmap concat . forM (ic_imports icxt) $ \i -> + ; orphs <- fmap concat . forM (ic_imports icxt) $ \i -> case i of IIModule n -> getOrphans n IIDecl i -> getOrphans (unLoc (ideclName i)) + ; let imports = emptyImportAvails { + imp_orphs = orphs + } ; (gbl_env, lcl_env) <- getEnvs ; let gbl_env' = gbl_env { tcg_rdr_env = ic_rn_gbl_env icxt @@ -1430,11 +1431,9 @@ runTcInteractive hsc_env thing_inside -- to make RecordWildCards work (test: ghci049) , tcg_fix_env = ic_fix_env icxt , tcg_default = ic_default icxt - , tcg_visible_orphan_mods = mkModuleSet ic_visible_mods - -- I guess there's a risk ic_imports will be - -- desynchronized with the true RdrEnv; probably - -- should insert some ASSERTs somehow. - -- TODO: Cache this + -- must calculate imp_orphs of the ImportAvails + -- so that instance visibility is done correctly + , tcg_imports = imports } ; lcl_env' <- tcExtendLocalTypeEnv lcl_env lcl_ids diff --git a/compiler/typecheck/TcRnMonad.hs b/compiler/typecheck/TcRnMonad.hs index c299f29234..3c69b9527b 100644 --- a/compiler/typecheck/TcRnMonad.hs +++ b/compiler/typecheck/TcRnMonad.hs @@ -133,7 +133,6 @@ initTc hsc_env hsc_src keep_rn_syntax mod loc do_this tcg_inst_env = emptyInstEnv, tcg_fam_inst_env = emptyFamInstEnv, tcg_ann_env = emptyAnnEnv, - tcg_visible_orphan_mods = mkModuleSet [mod], tcg_th_used = th_var, tcg_th_splice_used = th_splice_var, tcg_exports = [], diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs index 1509356721..cf7e39c88c 100644 --- a/compiler/typecheck/TcRnTypes.hs +++ b/compiler/typecheck/TcRnTypes.hs @@ -26,6 +26,7 @@ module TcRnTypes( Env(..), TcGblEnv(..), TcLclEnv(..), IfGblEnv(..), IfLclEnv(..), + tcVisibleOrphanMods, -- Renamer types ErrCtxt, RecFieldEnv(..), @@ -374,12 +375,6 @@ data TcGblEnv tcg_fam_inst_env :: FamInstEnv, -- ^ Ditto for family instances tcg_ann_env :: AnnEnv, -- ^ And for annotations - tcg_visible_orphan_mods :: ModuleSet, - -- ^ The set of orphan modules which transitively reachable from - -- direct imports. We use this to figure out if an orphan instance - -- in the global InstEnv should be considered visible. - -- See Note [Instance lookup and orphan instances] in InstEnv - -- Now a bunch of things about this module that are simply -- accumulated, but never consulted until the end. -- Nevertheless, it's convenient to accumulate them along @@ -499,6 +494,10 @@ data TcGblEnv -- ^ Wanted constraints of static forms. } +tcVisibleOrphanMods :: TcGblEnv -> ModuleSet +tcVisibleOrphanMods tcg_env + = mkModuleSet (tcg_mod tcg_env : imp_orphs (tcg_imports tcg_env)) + -- Note [Signature parameters in TcGblEnv and DynFlags] -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- When compiling signature files, we need to know which implementation |