import TypeRep ( Type(..), PredType(..) )
import TyCon ( TyCon, tyConName )
import HscTypes ( ExternalPackageState(..), PackageInstEnv,
- TyThing(..), implicitTyThings,
+ TyThing(..), implicitTyThings, typeEnvIds,
ModIface(..), ModDetails(..), InstPool,
TypeEnv, mkTypeEnv, extendTypeEnvList, lookupTypeEnv,
DeclPool, RulePool, Pool(..), Gated, addRuleToPool )
; let { (inst_pool', iface_insts)
= selectInsts (eps_insts eps) cls_gate tc_gates }
- ; traceTc (text "loadImportedInsts" <+> vcat [ppr cls <+> ppr tys,
- text "new pool" <+> ppr inst_pool',
- text "new insts" <+> ppr iface_insts])
-
-- Empty => finish up rapidly, without writing to eps
; if null iface_insts then
return (eps_inst_env eps)
-- Check for type consistency in the unfolding
ifOptM Opt_DoCoreLinting (
- case lintUnfolding noSrcLoc [{- in scope -}] core_expr' of
+ get_in_scope_ids `thenM` \ in_scope ->
+ case lintUnfolding noSrcLoc in_scope core_expr' of
Nothing -> returnM ()
Just fail_msg -> pprPanic "Iface Lint failure" (doc <+> fail_msg)
) `thenM_`
returnM core_expr'
where
doc = text "Unfolding of" <+> ppr name
+ get_in_scope_ids -- Urgh; but just for linting
+ = setLclEnv () $
+ do { env <- getGblEnv
+ ; case if_rec_types env of {
+ Nothing -> return [] ;
+ Just (_, get_env) -> do
+ { type_env <- get_env
+ ; return (typeEnvIds type_env) }}}
\end{code}
-- Deal with the type declarations; first bring their stuff
-- into scope, then rname them, then type check them
- (rdr_env, imports) <- importsFromLocalDecls $
- HsGroup { hs_tyclds = decls, hs_valds = EmptyBinds, hs_fords = [] } ;
- -- Rather clumsy; lots of unused fields
+ (rdr_env, imports) <- importsFromLocalDecls (mkFakeGroup decls) ;
updGblEnv (\gbl -> gbl { tcg_rdr_env = rdr_env `plusGlobalRdrEnv` tcg_rdr_env gbl,
tcg_imports = imports `plusImportAvails` tcg_imports gbl })
return mod_guts
}}}}
+
+mkFakeGroup decls -- Rather clumsy; lots of unused fields
+ = HsGroup { hs_tyclds = decls, -- This is the one we want
+ hs_valds = EmptyBinds, hs_fords = [],
+ hs_instds = [], hs_fixds = [], hs_depds = [],
+ hs_ruleds = [] }
\end{code}