{-# LANGUAGE NondecreasingIndentation #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
module GHC.Tc.Utils.Backpack (
findExtraSigImports,
implicitRequirements,
implicitRequirementsShallow,
checkUnit,
tcRnCheckUnit,
tcRnMergeSignatures,
mergeSignatures,
tcRnInstantiateSignature,
instantiateSignature,
) where
import GHC.Prelude
import GHC.Driver.Env
import GHC.Driver.Ppr
import GHC.Driver.Session
import GHC.Types.Basic (TypeOrKind(..))
import GHC.Types.Fixity (defaultFixity)
import GHC.Types.Fixity.Env
import GHC.Types.TypeEnv
import GHC.Types.Name.Reader
import GHC.Types.Id
import GHC.Types.Name
import GHC.Types.Name.Env
import GHC.Types.Name.Set
import GHC.Types.Avail
import GHC.Types.SrcLoc
import GHC.Types.SourceFile
import GHC.Types.Var
import GHC.Types.Unique.DSet
import GHC.Types.Name.Shape
import GHC.Types.PkgQual
import GHC.Unit
import GHC.Unit.Finder
import GHC.Unit.Module.Warnings
import GHC.Unit.Module.ModIface
import GHC.Unit.Module.ModDetails
import GHC.Unit.Module.Imported
import GHC.Unit.Module.Deps
import GHC.Tc.Errors.Types
import GHC.Tc.Gen.Export
import GHC.Tc.Solver
import GHC.Tc.TyCl.Utils
import GHC.Tc.Types.Constraint
import GHC.Tc.Types.Origin
import GHC.Tc.Utils.Monad
import GHC.Tc.Utils.Instantiate
import GHC.Tc.Utils.TcMType
import GHC.Tc.Utils.TcType
import GHC.Hs
import GHC.Core.InstEnv
import GHC.Core.FamInstEnv
import GHC.Core.Type
import GHC.Core.Multiplicity
import GHC.IfaceToCore
import GHC.Iface.Load
import GHC.Iface.Rename
import GHC.Iface.Syntax
import GHC.Rename.Names
import GHC.Rename.Fixity ( lookupFixityRn )
import GHC.Tc.Utils.Env
import GHC.Tc.Errors
import GHC.Tc.Utils.Unify
import GHC.Utils.Error
import GHC.Utils.Outputable
import GHC.Utils.Panic
import GHC.Utils.Panic.Plain
import GHC.Data.FastString
import GHC.Data.Maybe
import Control.Monad
import Data.List (find)
import {-# SOURCE #-} GHC.Tc.Module
fixityMisMatch :: TyThing -> Fixity -> Fixity -> TcRnMessage
fixityMisMatch :: TyThing -> Fixity -> Fixity -> TcRnMessage
fixityMisMatch TyThing
real_thing Fixity
real_fixity Fixity
sig_fixity =
forall a. (Diagnostic a, Typeable a) => a -> TcRnMessage
TcRnUnknownMessage forall a b. (a -> b) -> a -> b
$ [GhcHint] -> SDoc -> DiagnosticMessage
mkPlainError [GhcHint]
noHints forall a b. (a -> b) -> a -> b
$
[SDoc] -> SDoc
vcat [forall a. Outputable a => a -> SDoc
ppr TyThing
real_thing SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"has conflicting fixities in the module",
String -> SDoc
text String
"and its hsig file",
String -> SDoc
text String
"Main module:" SDoc -> SDoc -> SDoc
<+> Fixity -> SDoc
ppr_fix Fixity
real_fixity,
String -> SDoc
text String
"Hsig file:" SDoc -> SDoc -> SDoc
<+> Fixity -> SDoc
ppr_fix Fixity
sig_fixity]
where
ppr_fix :: Fixity -> SDoc
ppr_fix Fixity
f =
forall a. Outputable a => a -> SDoc
ppr Fixity
f SDoc -> SDoc -> SDoc
<+>
(if Fixity
f forall a. Eq a => a -> a -> Bool
== Fixity
defaultFixity
then SDoc -> SDoc
parens (String -> SDoc
text String
"default")
else SDoc
empty)
checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn ()
checkHsigDeclM :: ModIface -> TyThing -> TyThing -> TcRn ()
checkHsigDeclM ModIface
sig_iface TyThing
sig_thing TyThing
real_thing = do
let name :: Name
name = forall a. NamedThing a => a -> Name
getName TyThing
real_thing
Bool -> TyThing -> TyThing -> TcRn ()
checkBootDeclM Bool
False TyThing
sig_thing TyThing
real_thing
Fixity
real_fixity <- Name -> RnM Fixity
lookupFixityRn Name
name
let sig_fixity :: Fixity
sig_fixity = case ModIfaceBackend -> OccName -> Maybe Fixity
mi_fix_fn (forall (phase :: ModIfacePhase).
ModIface_ phase -> IfaceBackendExts phase
mi_final_exts ModIface
sig_iface) (forall name. HasOccName name => name -> OccName
occName Name
name) of
Maybe Fixity
Nothing -> Fixity
defaultFixity
Just Fixity
f -> Fixity
f
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Fixity
real_fixity forall a. Eq a => a -> a -> Bool
/= Fixity
sig_fixity) forall a b. (a -> b) -> a -> b
$
SrcSpan -> TcRnMessage -> TcRn ()
addErrAt (Name -> SrcSpan
nameSrcSpan Name
name)
(TyThing -> Fixity -> Fixity -> TcRnMessage
fixityMisMatch TyThing
real_thing Fixity
real_fixity Fixity
sig_fixity)
checkHsigIface :: TcGblEnv -> GlobalRdrEnv -> ModIface -> ModDetails -> TcRn ()
checkHsigIface :: TcGblEnv -> GlobalRdrEnv -> ModIface -> ModDetails -> TcRn ()
checkHsigIface TcGblEnv
tcg_env GlobalRdrEnv
gr ModIface
sig_iface
ModDetails { md_insts :: ModDetails -> InstEnv
md_insts = InstEnv
sig_insts, md_fam_insts :: ModDetails -> [FamInst]
md_fam_insts = [FamInst]
sig_fam_insts,
md_types :: ModDetails -> TypeEnv
md_types = TypeEnv
sig_type_env, md_exports :: ModDetails -> [AvailInfo]
md_exports = [AvailInfo]
sig_exports } = do
String -> SDoc -> TcRn ()
traceTc String
"checkHsigIface" forall a b. (a -> b) -> a -> b
$ [SDoc] -> SDoc
vcat
[ forall a. Outputable a => a -> SDoc
ppr TypeEnv
sig_type_env, forall a. Outputable a => a -> SDoc
ppr InstEnv
sig_insts, forall a. Outputable a => a -> SDoc
ppr [AvailInfo]
sig_exports ]
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Name -> TcRn ()
check_export (forall a b. (a -> b) -> [a] -> [b]
map AvailInfo -> Name
availName [AvailInfo]
sig_exports)
TcRn ()
failIfErrsM
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (forall (t :: * -> *) a. Foldable t => t a -> Bool
null [FamInst]
sig_fam_insts) forall a b. (a -> b) -> a -> b
$
forall a. String -> a
panic (String
"GHC.Tc.Module.checkHsigIface: Cannot handle family " forall a. [a] -> [a] -> [a]
++
String
"instances in hsig files yet...")
TcGblEnv
tcg_env <- forall gbl lcl. TcRnIf gbl lcl gbl
getGblEnv
forall gbl' lcl a gbl.
gbl' -> TcRnIf gbl' lcl a -> TcRnIf gbl lcl a
setGblEnv TcGblEnv
tcg_env { tcg_inst_env :: InstEnv
tcg_inst_env = InstEnv
emptyInstEnv,
tcg_fam_inst_env :: FamInstEnv
tcg_fam_inst_env = FamInstEnv
emptyFamInstEnv,
tcg_insts :: [ClsInst]
tcg_insts = [],
tcg_fam_insts :: [FamInst]
tcg_fam_insts = [] } forall a b. (a -> b) -> a -> b
$ do
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ ClsInst -> TcRn ()
check_inst (InstEnv -> [ClsInst]
instEnvElts InstEnv
sig_insts)
TcRn ()
failIfErrsM
where
sig_type_occ_env :: OccEnv TyThing
sig_type_occ_env = forall a. [(OccName, a)] -> OccEnv a
mkOccEnv
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map (\TyThing
t -> (Name -> OccName
nameOccName (forall a. NamedThing a => a -> Name
getName TyThing
t), TyThing
t))
forall a b. (a -> b) -> a -> b
$ forall a. NameEnv a -> [a]
nonDetNameEnvElts TypeEnv
sig_type_env
dfun_names :: [Name]
dfun_names = forall a b. (a -> b) -> [a] -> [b]
map forall a. NamedThing a => a -> Name
getName (InstEnv -> [ClsInst]
instEnvElts InstEnv
sig_insts)
check_export :: Name -> TcRn ()
check_export Name
name
| Name
name forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Name]
dfun_names = forall (m :: * -> *) a. Monad m => a -> m a
return ()
| Just TyThing
sig_thing <- forall a. OccEnv a -> OccName -> Maybe a
lookupOccEnv OccEnv TyThing
sig_type_occ_env (Name -> OccName
nameOccName Name
name) = do
MaybeErr SDoc TyThing
r <- Name -> TcM (MaybeErr SDoc TyThing)
tcLookupImported_maybe Name
name
case MaybeErr SDoc TyThing
r of
Failed SDoc
err -> TcRnMessage -> TcRn ()
addErr (forall a. (Diagnostic a, Typeable a) => a -> TcRnMessage
TcRnUnknownMessage forall a b. (a -> b) -> a -> b
$ [GhcHint] -> SDoc -> DiagnosticMessage
mkPlainError [GhcHint]
noHints SDoc
err)
Succeeded TyThing
real_thing -> ModIface -> TyThing -> TyThing -> TcRn ()
checkHsigDeclM ModIface
sig_iface TyThing
sig_thing TyThing
real_thing
| [GlobalRdrElt
gre] <- GlobalRdrEnv -> OccName -> [GlobalRdrElt]
lookupGlobalRdrEnv GlobalRdrEnv
gr (Name -> OccName
nameOccName Name
name) = do
let name' :: Name
name' = GlobalRdrElt -> Name
greMangledName GlobalRdrElt
gre
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Name
name forall a. Eq a => a -> a -> Bool
/= Name
name') forall a b. (a -> b) -> a -> b
$ do
let p :: GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed))
-> Bool
p (L SrcSpanAnn' (EpAnn AnnListItem)
_ IE (GhcPass 'Renamed)
ie) = Name
name forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` forall (p :: Pass). IE (GhcPass p) -> [IdP (GhcPass p)]
ieNames IE (GhcPass 'Renamed)
ie
loc :: SrcSpan
loc = case TcGblEnv -> Maybe [(LIE (GhcPass 'Renamed), [AvailInfo])]
tcg_rn_exports TcGblEnv
tcg_env of
Just [(LIE (GhcPass 'Renamed), [AvailInfo])]
es | Just GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed))
e <- forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed))
-> Bool
p (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(LIE (GhcPass 'Renamed), [AvailInfo])]
es)
-> forall a e. GenLocated (SrcSpanAnn' a) e -> SrcSpan
getLocA GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed))
e
Maybe [(LIE (GhcPass 'Renamed), [AvailInfo])]
_ -> Name -> SrcSpan
nameSrcSpan Name
name
SrcSpan -> TcRnMessage -> TcRn ()
addErrAt SrcSpan
loc
(Bool -> Name -> Name -> TcRnMessage
badReexportedBootThing Bool
False Name
name Name
name')
| Bool
otherwise =
SrcSpan -> TcRnMessage -> TcRn ()
addErrAt (Name -> SrcSpan
nameSrcSpan Name
name)
(Bool -> Name -> String -> TcRnMessage
missingBootThing Bool
False Name
name String
"exported by")
check_inst :: ClsInst -> TcM ()
check_inst :: ClsInst -> TcRn ()
check_inst ClsInst
sig_inst = do
TcGblEnv
tcg_env <- forall gbl lcl. TcRnIf gbl lcl gbl
getGblEnv
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Name -> TcM (MaybeErr SDoc TyThing)
tcLookupImported_maybe (NameSet -> [Name]
nameSetElemsStable (ClsInst -> NameSet
orphNamesOfClsInst ClsInst
sig_inst))
let ty :: Kind
ty = Id -> Kind
idType (ClsInst -> Id
instanceDFunId ClsInst
sig_inst)
([Id]
tvs, [Scaled Kind]
theta, Kind
pred) =
case Kind -> ([Id], Kind)
tcSplitForAllInvisTyVars Kind
ty of { ([Id]
tvs, Kind
rho) ->
case Kind -> ([Scaled Kind], Kind)
splitFunTys Kind
rho of { ([Scaled Kind]
theta, Kind
pred) ->
([Id]
tvs, [Scaled Kind]
theta, Kind
pred) }}
origin :: CtOrigin
origin = Module -> ClsInst -> CtOrigin
InstProvidedOrigin (TcGblEnv -> Module
tcg_semantic_mod TcGblEnv
tcg_env) ClsInst
sig_inst
SkolemInfo
skol_info <- forall (m :: * -> *). MonadIO m => SkolemInfoAnon -> m SkolemInfo
mkSkolemInfo SkolemInfoAnon
InstSkol
(TCvSubst
skol_subst, [Id]
tvs_skols) <- SkolemInfo -> [Id] -> TcM (TCvSubst, [Id])
tcInstSkolTyVars SkolemInfo
skol_info [Id]
tvs
(TcLevel
tclvl,[CtEvidence]
cts) <- forall a. TcM a -> TcM (TcLevel, a)
pushTcLevelM forall a b. (a -> b) -> a -> b
$ do
CtEvidence
wanted <- CtOrigin -> Maybe TypeOrKind -> Kind -> TcM CtEvidence
newWanted CtOrigin
origin
(forall a. a -> Maybe a
Just TypeOrKind
TypeLevel)
(HasDebugCallStack => TCvSubst -> Kind -> Kind
substTy TCvSubst
skol_subst Kind
pred)
[CtEvidence]
givens <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [Scaled Kind]
theta forall a b. (a -> b) -> a -> b
$ \Scaled Kind
given -> do
CtLoc
loc <- CtOrigin -> Maybe TypeOrKind -> TcM CtLoc
getCtLocM CtOrigin
origin (forall a. a -> Maybe a
Just TypeOrKind
TypeLevel)
let given_pred :: Kind
given_pred = HasDebugCallStack => TCvSubst -> Kind -> Kind
substTy TCvSubst
skol_subst (forall a. Scaled a -> a
scaledThing Scaled Kind
given)
Id
new_ev <- forall gbl lcl. Kind -> TcRnIf gbl lcl Id
newEvVar Kind
given_pred
forall (m :: * -> *) a. Monad m => a -> m a
return CtGiven { ctev_pred :: Kind
ctev_pred = Kind
given_pred
, ctev_evar :: Id
ctev_evar = Id
new_ev
, ctev_loc :: CtLoc
ctev_loc = CtLoc
loc
}
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ CtEvidence
wanted forall a. a -> [a] -> [a]
: [CtEvidence]
givens
WantedConstraints
unsolved <- [CtEvidence] -> TcM WantedConstraints
simplifyWantedsTcM [CtEvidence]
cts
(Bag Implication
implic, TcEvBinds
_) <- TcLevel
-> SkolemInfoAnon
-> [Id]
-> [Id]
-> WantedConstraints
-> TcM (Bag Implication, TcEvBinds)
buildImplicationFor TcLevel
tclvl (SkolemInfo -> SkolemInfoAnon
getSkolemInfo SkolemInfo
skol_info) [Id]
tvs_skols [] WantedConstraints
unsolved
WantedConstraints -> TcRn ()
reportAllUnsolved (Bag Implication -> WantedConstraints
mkImplicWC Bag Implication
implic)
findExtraSigImports :: HscEnv
-> HscSource
-> ModuleName
-> IO [ModuleName]
HscEnv
hsc_env HscSource
HsigFile ModuleName
modname = do
let
dflags :: DynFlags
dflags = HscEnv -> DynFlags
hsc_dflags HscEnv
hsc_env
ctx :: SDocContext
ctx = DynFlags -> PprStyle -> SDocContext
initSDocContext DynFlags
dflags PprStyle
defaultUserStyle
unit_state :: UnitState
unit_state = HasDebugCallStack => HscEnv -> UnitState
hsc_units HscEnv
hsc_env
reqs :: [InstantiatedModule]
reqs = UnitState -> ModuleName -> [InstantiatedModule]
requirementMerges UnitState
unit_state ModuleName
modname
[UniqDSet ModuleName]
holes <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [InstantiatedModule]
reqs forall a b. (a -> b) -> a -> b
$ \(Module InstantiatedUnit
iuid ModuleName
mod_name) -> do
forall a. HscEnv -> IfG a -> IO a
initIfaceLoad HscEnv
hsc_env
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
MonadIO m =>
SDocContext -> m (MaybeErr SDoc a) -> m a
withException SDocContext
ctx
forall a b. (a -> b) -> a -> b
$ forall gbl lcl.
SDoc
-> Module -> TcRnIf gbl lcl (MaybeErr SDoc (UniqDSet ModuleName))
moduleFreeHolesPrecise (String -> SDoc
text String
"findExtraSigImports")
(forall u. u -> ModuleName -> GenModule u
mkModule (forall uid. GenInstantiatedUnit uid -> GenUnit uid
VirtUnit InstantiatedUnit
iuid) ModuleName
mod_name)
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. UniqDSet a -> [a]
uniqDSetToList (forall a. [UniqDSet a] -> UniqDSet a
unionManyUniqDSets [UniqDSet ModuleName]
holes))
findExtraSigImports HscEnv
_ HscSource
_ ModuleName
_ = forall (m :: * -> *) a. Monad m => a -> m a
return []
implicitRequirements :: HscEnv
-> [(PkgQual, Located ModuleName)]
-> IO [ModuleName]
implicitRequirements :: HscEnv -> [(PkgQual, Located ModuleName)] -> IO [ModuleName]
implicitRequirements HscEnv
hsc_env [(PkgQual, Located ModuleName)]
normal_imports
= forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat forall a b. (a -> b) -> a -> b
$
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [(PkgQual, Located ModuleName)]
normal_imports forall a b. (a -> b) -> a -> b
$ \(PkgQual
mb_pkg, L SrcSpan
_ ModuleName
imp) -> do
FindResult
found <- HscEnv -> ModuleName -> PkgQual -> IO FindResult
findImportedModule HscEnv
hsc_env ModuleName
imp PkgQual
mb_pkg
case FindResult
found of
Found ModLocation
_ Module
mod | Maybe HomeUnit -> Module -> Bool
notHomeModuleMaybe Maybe HomeUnit
mhome_unit Module
mod ->
forall (m :: * -> *) a. Monad m => a -> m a
return (forall a. UniqDSet a -> [a]
uniqDSetToList (forall u. GenModule (GenUnit u) -> UniqDSet ModuleName
moduleFreeHoles Module
mod))
FindResult
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return []
where
mhome_unit :: Maybe HomeUnit
mhome_unit = HscEnv -> Maybe HomeUnit
hsc_home_unit_maybe HscEnv
hsc_env
implicitRequirementsShallow
:: HscEnv
-> [(PkgQual, Located ModuleName)]
-> IO ([ModuleName], [InstantiatedUnit])
implicitRequirementsShallow :: HscEnv
-> [(PkgQual, Located ModuleName)]
-> IO ([ModuleName], [InstantiatedUnit])
implicitRequirementsShallow HscEnv
hsc_env [(PkgQual, Located ModuleName)]
normal_imports = ([ModuleName], [InstantiatedUnit])
-> [(PkgQual, Located ModuleName)]
-> IO ([ModuleName], [InstantiatedUnit])
go ([], []) [(PkgQual, Located ModuleName)]
normal_imports
where
mhome_unit :: Maybe HomeUnit
mhome_unit = HscEnv -> Maybe HomeUnit
hsc_home_unit_maybe HscEnv
hsc_env
go :: ([ModuleName], [InstantiatedUnit])
-> [(PkgQual, Located ModuleName)]
-> IO ([ModuleName], [InstantiatedUnit])
go ([ModuleName], [InstantiatedUnit])
acc [] = forall (f :: * -> *) a. Applicative f => a -> f a
pure ([ModuleName], [InstantiatedUnit])
acc
go ([ModuleName]
accL, [InstantiatedUnit]
accR) ((PkgQual
mb_pkg, L SrcSpan
_ ModuleName
imp):[(PkgQual, Located ModuleName)]
imports) = do
FindResult
found <- HscEnv -> ModuleName -> PkgQual -> IO FindResult
findImportedModule HscEnv
hsc_env ModuleName
imp PkgQual
mb_pkg
let acc' :: ([ModuleName], [InstantiatedUnit])
acc' = case FindResult
found of
Found ModLocation
_ Module
mod | Maybe HomeUnit -> Module -> Bool
notHomeModuleMaybe Maybe HomeUnit
mhome_unit Module
mod ->
case forall unit. GenModule unit -> unit
moduleUnit Module
mod of
Unit
HoleUnit -> (forall unit. GenModule unit -> ModuleName
moduleName Module
mod forall a. a -> [a] -> [a]
: [ModuleName]
accL, [InstantiatedUnit]
accR)
RealUnit Definite UnitId
_ -> ([ModuleName]
accL, [InstantiatedUnit]
accR)
VirtUnit InstantiatedUnit
u -> ([ModuleName]
accL, InstantiatedUnit
uforall a. a -> [a] -> [a]
:[InstantiatedUnit]
accR)
FindResult
_ -> ([ModuleName]
accL, [InstantiatedUnit]
accR)
([ModuleName], [InstantiatedUnit])
-> [(PkgQual, Located ModuleName)]
-> IO ([ModuleName], [InstantiatedUnit])
go ([ModuleName], [InstantiatedUnit])
acc' [(PkgQual, Located ModuleName)]
imports
checkUnit :: Unit -> TcM ()
checkUnit :: Unit -> TcRn ()
checkUnit Unit
HoleUnit = forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkUnit (RealUnit Definite UnitId
_) = forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkUnit (VirtUnit InstantiatedUnit
indef) = do
let insts :: GenInstantiations UnitId
insts = forall unit. GenInstantiatedUnit unit -> GenInstantiations unit
instUnitInsts InstantiatedUnit
indef
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ GenInstantiations UnitId
insts forall a b. (a -> b) -> a -> b
$ \(ModuleName
mod_name, Module
mod) ->
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool -> Bool
not (forall u. GenModule (GenUnit u) -> Bool
isHoleModule Module
mod)) forall a b. (a -> b) -> a -> b
$ do
Unit -> TcRn ()
checkUnit (forall unit. GenModule unit -> unit
moduleUnit Module
mod)
TcGblEnv
_ <- Module
mod Module -> InstantiatedModule -> TcRn TcGblEnv
`checkImplements` forall u. u -> ModuleName -> GenModule u
Module InstantiatedUnit
indef ModuleName
mod_name
forall (m :: * -> *) a. Monad m => a -> m a
return ()
tcRnCheckUnit ::
HscEnv -> Unit ->
IO (Messages TcRnMessage, Maybe ())
tcRnCheckUnit :: HscEnv -> Unit -> IO (Messages TcRnMessage, Maybe ())
tcRnCheckUnit HscEnv
hsc_env Unit
uid =
forall (m :: * -> *) a.
MonadIO m =>
Logger -> SDoc -> (a -> ()) -> m a -> m a
withTiming Logger
logger
(String -> SDoc
text String
"Check unit id" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Unit
uid)
(forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$
forall r.
HscEnv
-> HscSource
-> Bool
-> Module
-> RealSrcSpan
-> TcM r
-> IO (Messages TcRnMessage, Maybe r)
initTc HscEnv
hsc_env
HscSource
HsigFile
Bool
False
(HomeUnitEnv -> Module
mainModIs (HscEnv -> HomeUnitEnv
hsc_HUE HscEnv
hsc_env))
(RealSrcLoc -> RealSrcSpan
realSrcLocSpan (FastString -> Int -> Int -> RealSrcLoc
mkRealSrcLoc (String -> FastString
fsLit String
loc_str) Int
0 Int
0))
forall a b. (a -> b) -> a -> b
$ Unit -> TcRn ()
checkUnit Unit
uid
where
dflags :: DynFlags
dflags = HscEnv -> DynFlags
hsc_dflags HscEnv
hsc_env
logger :: Logger
logger = HscEnv -> Logger
hsc_logger HscEnv
hsc_env
loc_str :: String
loc_str = String
"Command line argument: -unit-id " forall a. [a] -> [a] -> [a]
++ DynFlags -> SDoc -> String
showSDoc DynFlags
dflags (forall a. Outputable a => a -> SDoc
ppr Unit
uid)
tcRnMergeSignatures :: HscEnv -> HsParsedModule -> TcGblEnv -> ModIface
-> IO (Messages TcRnMessage, Maybe TcGblEnv)
tcRnMergeSignatures :: HscEnv
-> HsParsedModule
-> TcGblEnv
-> ModIface
-> IO (Messages TcRnMessage, Maybe TcGblEnv)
tcRnMergeSignatures HscEnv
hsc_env HsParsedModule
hpm TcGblEnv
orig_tcg_env ModIface
iface =
forall (m :: * -> *) a.
MonadIO m =>
Logger -> SDoc -> (a -> ()) -> m a -> m a
withTiming Logger
logger
(String -> SDoc
text String
"Signature merging" SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
brackets (forall a. Outputable a => a -> SDoc
ppr Module
this_mod))
(forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$
forall r.
HscEnv
-> HscSource
-> Bool
-> Module
-> RealSrcSpan
-> TcM r
-> IO (Messages TcRnMessage, Maybe r)
initTc HscEnv
hsc_env HscSource
HsigFile Bool
False Module
this_mod RealSrcSpan
real_loc forall a b. (a -> b) -> a -> b
$
HsParsedModule -> TcGblEnv -> ModIface -> TcRn TcGblEnv
mergeSignatures HsParsedModule
hpm TcGblEnv
orig_tcg_env ModIface
iface
where
logger :: Logger
logger = HscEnv -> Logger
hsc_logger HscEnv
hsc_env
this_mod :: Module
this_mod = forall (phase :: ModIfacePhase). ModIface_ phase -> Module
mi_module ModIface
iface
real_loc :: RealSrcSpan
real_loc = TcGblEnv -> RealSrcSpan
tcg_top_loc TcGblEnv
orig_tcg_env
thinModIface :: [AvailInfo] -> ModIface -> ModIface
thinModIface :: [AvailInfo] -> ModIface -> ModIface
thinModIface [AvailInfo]
avails ModIface
iface =
ModIface
iface {
mi_exports :: [AvailInfo]
mi_exports = [AvailInfo]
avails,
mi_decls :: [IfaceDeclExts 'ModIfaceFinal]
mi_decls = [(Fingerprint, IfaceDecl)]
exported_decls forall a. [a] -> [a] -> [a]
++ [(Fingerprint, IfaceDecl)]
non_exported_decls forall a. [a] -> [a] -> [a]
++ [(Fingerprint, IfaceDecl)]
dfun_decls
}
where
decl_pred :: OccSet -> IfaceDecl -> Bool
decl_pred OccSet
occs IfaceDecl
decl = Name -> OccName
nameOccName (IfaceDecl -> Name
ifName IfaceDecl
decl) OccName -> OccSet -> Bool
`elemOccSet` OccSet
occs
filter_decls :: OccSet -> [(Fingerprint, IfaceDecl)]
filter_decls OccSet
occs = forall a. (a -> Bool) -> [a] -> [a]
filter (OccSet -> IfaceDecl -> Bool
decl_pred OccSet
occs forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd) (forall (phase :: ModIfacePhase).
ModIface_ phase -> [IfaceDeclExts phase]
mi_decls ModIface
iface)
exported_occs :: OccSet
exported_occs = [OccName] -> OccSet
mkOccSet [ forall name. HasOccName name => name -> OccName
occName Name
n
| AvailInfo
a <- [AvailInfo]
avails
, Name
n <- AvailInfo -> [Name]
availNames AvailInfo
a ]
exported_decls :: [(Fingerprint, IfaceDecl)]
exported_decls = OccSet -> [(Fingerprint, IfaceDecl)]
filter_decls OccSet
exported_occs
non_exported_occs :: OccSet
non_exported_occs = [OccName] -> OccSet
mkOccSet [ forall name. HasOccName name => name -> OccName
occName Name
n
| (Fingerprint
_, IfaceDecl
d) <- [(Fingerprint, IfaceDecl)]
exported_decls
, Name
n <- IfaceDecl -> [Name]
ifaceDeclNeverExportedRefs IfaceDecl
d ]
non_exported_decls :: [(Fingerprint, IfaceDecl)]
non_exported_decls = OccSet -> [(Fingerprint, IfaceDecl)]
filter_decls OccSet
non_exported_occs
dfun_pred :: IfaceDecl -> Bool
dfun_pred IfaceId{ ifIdDetails :: IfaceDecl -> IfaceIdDetails
ifIdDetails = IfaceIdDetails
IfDFunId } = Bool
True
dfun_pred IfaceDecl
_ = Bool
False
dfun_decls :: [(Fingerprint, IfaceDecl)]
dfun_decls = forall a. (a -> Bool) -> [a] -> [a]
filter (IfaceDecl -> Bool
dfun_pred forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a, b) -> b
snd) (forall (phase :: ModIfacePhase).
ModIface_ phase -> [IfaceDeclExts phase]
mi_decls ModIface
iface)
ifaceDeclNeverExportedRefs :: IfaceDecl -> [Name]
ifaceDeclNeverExportedRefs :: IfaceDecl -> [Name]
ifaceDeclNeverExportedRefs d :: IfaceDecl
d@IfaceFamily{} =
case IfaceDecl -> IfaceFamTyConFlav
ifFamFlav IfaceDecl
d of
IfaceClosedSynFamilyTyCon (Just (Name
n, [IfaceAxBranch]
_))
-> [Name
n]
IfaceFamTyConFlav
_ -> []
ifaceDeclNeverExportedRefs IfaceDecl
_ = []
merge_msg :: ModuleName -> [InstantiatedModule] -> SDoc
merge_msg :: ModuleName -> [InstantiatedModule] -> SDoc
merge_msg ModuleName
mod_name [] =
String -> SDoc
text String
"while checking the local signature" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr ModuleName
mod_name SDoc -> SDoc -> SDoc
<+>
String -> SDoc
text String
"for consistency"
merge_msg ModuleName
mod_name [InstantiatedModule]
reqs =
SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"while merging the signatures from" SDoc -> SDoc -> SDoc
<> SDoc
colon)
Int
2 ([SDoc] -> SDoc
vcat [ SDoc
bullet SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr InstantiatedModule
req | InstantiatedModule
req <- [InstantiatedModule]
reqs ] SDoc -> SDoc -> SDoc
$$
SDoc
bullet SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"...and the local signature for" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr ModuleName
mod_name)
mergeSignatures :: HsParsedModule -> TcGblEnv -> ModIface -> TcRn TcGblEnv
mergeSignatures :: HsParsedModule -> TcGblEnv -> ModIface -> TcRn TcGblEnv
mergeSignatures
(HsParsedModule { hpm_module :: HsParsedModule -> Located HsModule
hpm_module = L SrcSpan
loc (HsModule { hsmodExports :: HsModule -> Maybe (LocatedL [LIE GhcPs])
hsmodExports = Maybe (LocatedL [LIE GhcPs])
mb_exports }),
hpm_src_files :: HsParsedModule -> [String]
hpm_src_files = [String]
src_files })
TcGblEnv
orig_tcg_env ModIface
lcl_iface0 = forall a. SrcSpan -> TcRn a -> TcRn a
setSrcSpan SrcSpan
loc forall a b. (a -> b) -> a -> b
$ do
HscEnv
hsc_env <- forall gbl lcl. TcRnIf gbl lcl HscEnv
getTopEnv
forall gbl lcl a.
(gbl -> gbl) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
updGblEnv (\TcGblEnv
env -> TcGblEnv
env {
tcg_rn_imports :: [LImportDecl (GhcPass 'Renamed)]
tcg_rn_imports = TcGblEnv -> [LImportDecl (GhcPass 'Renamed)]
tcg_rn_imports TcGblEnv
orig_tcg_env,
tcg_rn_decls :: Maybe (HsGroup (GhcPass 'Renamed))
tcg_rn_decls = TcGblEnv -> Maybe (HsGroup (GhcPass 'Renamed))
tcg_rn_decls TcGblEnv
orig_tcg_env,
tcg_ann_env :: AnnEnv
tcg_ann_env = TcGblEnv -> AnnEnv
tcg_ann_env TcGblEnv
orig_tcg_env,
tcg_doc_hdr :: Maybe (LHsDoc (GhcPass 'Renamed))
tcg_doc_hdr = TcGblEnv -> Maybe (LHsDoc (GhcPass 'Renamed))
tcg_doc_hdr TcGblEnv
orig_tcg_env
}) forall a b. (a -> b) -> a -> b
$ do
TcGblEnv
tcg_env <- forall gbl lcl. TcRnIf gbl lcl gbl
getGblEnv
let outer_mod :: Module
outer_mod = TcGblEnv -> Module
tcg_mod TcGblEnv
tcg_env
let inner_mod :: Module
inner_mod = TcGblEnv -> Module
tcg_semantic_mod TcGblEnv
tcg_env
let mod_name :: ModuleName
mod_name = forall unit. GenModule unit -> ModuleName
moduleName (TcGblEnv -> Module
tcg_mod TcGblEnv
tcg_env)
let unit_state :: UnitState
unit_state = HasDebugCallStack => HscEnv -> UnitState
hsc_units HscEnv
hsc_env
let dflags :: DynFlags
dflags = HscEnv -> DynFlags
hsc_dflags HscEnv
hsc_env
let reqs :: [InstantiatedModule]
reqs = UnitState -> ModuleName -> [InstantiatedModule]
requirementMerges UnitState
unit_state ModuleName
mod_name
forall a. SDoc -> TcM a -> TcM a
addErrCtxt (UnitState -> SDoc -> SDoc
pprWithUnitState UnitState
unit_state forall a b. (a -> b) -> a -> b
$ ModuleName -> [InstantiatedModule] -> SDoc
merge_msg ModuleName
mod_name [InstantiatedModule]
reqs) forall a b. (a -> b) -> a -> b
$ do
[ModIface]
ireq_ifaces0 <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [InstantiatedModule]
reqs forall a b. (a -> b) -> a -> b
$ \(Module InstantiatedUnit
iuid ModuleName
mod_name) -> do
let m :: Module
m = forall u. u -> ModuleName -> GenModule u
mkModule (forall uid. GenInstantiatedUnit uid -> GenUnit uid
VirtUnit InstantiatedUnit
iuid) ModuleName
mod_name
im :: InstalledModule
im = forall a b. (a, b) -> a
fst (Module -> (InstalledModule, Maybe InstantiatedModule)
getModuleInstantiation Module
m)
ctx :: SDocContext
ctx = DynFlags -> PprStyle -> SDocContext
initSDocContext DynFlags
dflags PprStyle
defaultUserStyle
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap forall a b. (a, b) -> a
fst
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (m :: * -> *) a.
MonadIO m =>
SDocContext -> m (MaybeErr SDoc a) -> m a
withException SDocContext
ctx
forall a b. (a -> b) -> a -> b
$ HscEnv
-> SDoc
-> InstalledModule
-> Module
-> IsBootInterface
-> IO (MaybeErr SDoc (ModIface, String))
findAndReadIface HscEnv
hsc_env
(String -> SDoc
text String
"mergeSignatures") InstalledModule
im Module
m IsBootInterface
NotBoot
let extend_ns :: NameShape
-> [AvailInfo]
-> IOEnv (Env TcGblEnv TcLclEnv) (Either SDoc NameShape)
extend_ns NameShape
nsubst [AvailInfo]
as = forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ HscEnv -> NameShape -> [AvailInfo] -> IO (Either SDoc NameShape)
extendNameShape HscEnv
hsc_env NameShape
nsubst [AvailInfo]
as
gen_subst :: (NameShape, OccSet, [(InstantiatedModule, ModIface)])
-> (InstantiatedModule, ModIface)
-> IOEnv
(Env TcGblEnv TcLclEnv)
(NameShape, OccSet, [(InstantiatedModule, ModIface)])
gen_subst (NameShape
nsubst,OccSet
oks,[(InstantiatedModule, ModIface)]
ifaces) (imod :: InstantiatedModule
imod@(Module InstantiatedUnit
iuid ModuleName
_), ModIface
ireq_iface) = do
let insts :: GenInstantiations UnitId
insts = forall unit. GenInstantiatedUnit unit -> GenInstantiations unit
instUnitInsts InstantiatedUnit
iuid
isFromSignaturePackage :: Bool
isFromSignaturePackage =
let inst_uid :: UnitId
inst_uid = forall unit. GenInstantiatedUnit unit -> unit
instUnitInstanceOf InstantiatedUnit
iuid
pkg :: UnitInfo
pkg = HasDebugCallStack => UnitState -> UnitId -> UnitInfo
unsafeLookupUnitId UnitState
unit_state UnitId
inst_uid
in forall (t :: * -> *) a. Foldable t => t a -> Bool
null (forall srcpkgid srcpkgname uid modulename mod.
GenericUnitInfo srcpkgid srcpkgname uid modulename mod
-> [(modulename, Maybe mod)]
unitExposedModules UnitInfo
pkg)
[AvailInfo]
as1 <- GenInstantiations UnitId -> ModIface -> TcM [AvailInfo]
tcRnModExports GenInstantiations UnitId
insts ModIface
ireq_iface
(ModIface
thinned_iface, [AvailInfo]
as2) <- case Maybe (LocatedL [LIE GhcPs])
mb_exports of
Just (L SrcSpanAnnL
loc [LIE GhcPs]
_)
| Bool
isFromSignaturePackage
-> forall ann a. SrcSpanAnn' ann -> TcRn a -> TcRn a
setSrcSpanA SrcSpanAnnL
loc forall a b. (a -> b) -> a -> b
$ do
(Maybe
(Maybe
[(GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed)),
[AvailInfo])],
[AvailInfo])
mb_r, Messages TcRnMessage
msgs) <- forall a. TcRn a -> TcRn (Maybe a, Messages TcRnMessage)
tryTc forall a b. (a -> b) -> a -> b
$ do
let ispec :: ImportSpec
ispec = ImpDeclSpec -> ImpItemSpec -> ImportSpec
ImpSpec ImpDeclSpec{
is_mod :: ModuleName
is_mod = ModuleName
mod_name,
is_as :: ModuleName
is_as = ModuleName
mod_name,
is_qual :: Bool
is_qual = Bool
False,
is_dloc :: SrcSpan
is_dloc = forall a. SrcSpanAnn' a -> SrcSpan
locA SrcSpanAnnL
loc
} ImpItemSpec
ImpAll
rdr_env :: GlobalRdrEnv
rdr_env = [GlobalRdrElt] -> GlobalRdrEnv
mkGlobalRdrEnv (Maybe ImportSpec -> [AvailInfo] -> [GlobalRdrElt]
gresFromAvails (forall a. a -> Maybe a
Just ImportSpec
ispec) [AvailInfo]
as1)
forall gbl' lcl a gbl.
gbl' -> TcRnIf gbl' lcl a -> TcRnIf gbl lcl a
setGblEnv TcGblEnv
tcg_env {
tcg_rdr_env :: GlobalRdrEnv
tcg_rdr_env = GlobalRdrEnv
rdr_env
} forall a b. (a -> b) -> a -> b
$ Maybe (LocatedL [LIE GhcPs])
-> GlobalRdrEnv
-> ImportAvails
-> Module
-> TcRnIf
TcGblEnv
TcLclEnv
(Maybe [(LIE (GhcPass 'Renamed), [AvailInfo])], [AvailInfo])
exports_from_avail Maybe (LocatedL [LIE GhcPs])
mb_exports GlobalRdrEnv
rdr_env
ImportAvails
emptyImportAvails
(TcGblEnv -> Module
tcg_semantic_mod TcGblEnv
tcg_env)
case Maybe
(Maybe
[(GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed)),
[AvailInfo])],
[AvailInfo])
mb_r of
Just (Maybe
[(GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed)),
[AvailInfo])]
_, [AvailInfo]
as2) -> forall (m :: * -> *) a. Monad m => a -> m a
return ([AvailInfo] -> ModIface -> ModIface
thinModIface [AvailInfo]
as2 ModIface
ireq_iface, [AvailInfo]
as2)
Maybe
(Maybe
[(GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed)),
[AvailInfo])],
[AvailInfo])
Nothing -> Messages TcRnMessage -> TcRn ()
addMessages Messages TcRnMessage
msgs forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> forall env a. IOEnv env a
failM
Maybe (LocatedL [LIE GhcPs])
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return (ModIface
ireq_iface, [AvailInfo]
as1)
let oks' :: OccSet
oks' | Bool
isFromSignaturePackage
= OccSet -> [OccName] -> OccSet
extendOccSetList OccSet
oks ([AvailInfo] -> [OccName]
exportOccs [AvailInfo]
as2)
| Bool
otherwise
= OccSet
oks
Either SDoc NameShape
mb_r <- NameShape
-> [AvailInfo]
-> IOEnv (Env TcGblEnv TcLclEnv) (Either SDoc NameShape)
extend_ns NameShape
nsubst [AvailInfo]
as2
case Either SDoc NameShape
mb_r of
Left SDoc
err -> forall a. TcRnMessage -> TcM a
failWithTc (forall a. (Diagnostic a, Typeable a) => a -> TcRnMessage
TcRnUnknownMessage forall a b. (a -> b) -> a -> b
$ [GhcHint] -> SDoc -> DiagnosticMessage
mkPlainError [GhcHint]
noHints SDoc
err)
Right NameShape
nsubst' -> forall (m :: * -> *) a. Monad m => a -> m a
return (NameShape
nsubst',OccSet
oks',(InstantiatedModule
imod, ModIface
thinned_iface)forall a. a -> [a] -> [a]
:[(InstantiatedModule, ModIface)]
ifaces)
nsubst0 :: NameShape
nsubst0 = ModuleName -> [AvailInfo] -> NameShape
mkNameShape (forall unit. GenModule unit -> ModuleName
moduleName Module
inner_mod) (forall (phase :: ModIfacePhase). ModIface_ phase -> [AvailInfo]
mi_exports ModIface
lcl_iface0)
ok_to_use0 :: OccSet
ok_to_use0 = [OccName] -> OccSet
mkOccSet ([AvailInfo] -> [OccName]
exportOccs (forall (phase :: ModIfacePhase). ModIface_ phase -> [AvailInfo]
mi_exports ModIface
lcl_iface0))
(NameShape
nsubst, OccSet
ok_to_use, [(InstantiatedModule, ModIface)]
rev_thinned_ifaces)
<- forall (t :: * -> *) (m :: * -> *) b a.
(Foldable t, Monad m) =>
(b -> a -> m b) -> b -> t a -> m b
foldM (NameShape, OccSet, [(InstantiatedModule, ModIface)])
-> (InstantiatedModule, ModIface)
-> IOEnv
(Env TcGblEnv TcLclEnv)
(NameShape, OccSet, [(InstantiatedModule, ModIface)])
gen_subst (NameShape
nsubst0, OccSet
ok_to_use0, []) (forall a b. [a] -> [b] -> [(a, b)]
zip [InstantiatedModule]
reqs [ModIface]
ireq_ifaces0)
let thinned_ifaces :: [(InstantiatedModule, ModIface)]
thinned_ifaces = forall a. [a] -> [a]
reverse [(InstantiatedModule, ModIface)]
rev_thinned_ifaces
exports :: [AvailInfo]
exports = NameShape -> [AvailInfo]
nameShapeExports NameShape
nsubst
rdr_env :: GlobalRdrEnv
rdr_env = [GlobalRdrElt] -> GlobalRdrEnv
mkGlobalRdrEnv (Maybe ImportSpec -> [AvailInfo] -> [GlobalRdrElt]
gresFromAvails forall a. Maybe a
Nothing [AvailInfo]
exports)
_warn_occs :: [OccName]
_warn_occs = forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not forall b c a. (b -> c) -> (a -> b) -> a -> c
. (OccName -> OccSet -> Bool
`elemOccSet` OccSet
ok_to_use)) ([AvailInfo] -> [OccName]
exportOccs [AvailInfo]
exports)
warns :: Warnings pass
warns = forall pass. Warnings pass
NoWarnings
forall gbl' lcl a gbl.
gbl' -> TcRnIf gbl' lcl a -> TcRnIf gbl lcl a
setGblEnv TcGblEnv
tcg_env {
tcg_rdr_env :: GlobalRdrEnv
tcg_rdr_env = GlobalRdrEnv
rdr_env GlobalRdrEnv -> GlobalRdrEnv -> GlobalRdrEnv
`plusGlobalRdrEnv` TcGblEnv -> GlobalRdrEnv
tcg_rdr_env TcGblEnv
orig_tcg_env,
tcg_imports :: ImportAvails
tcg_imports = TcGblEnv -> ImportAvails
tcg_imports TcGblEnv
orig_tcg_env,
tcg_exports :: [AvailInfo]
tcg_exports = [AvailInfo]
exports,
tcg_dus :: DefUses
tcg_dus = NameSet -> DefUses
usesOnly ([AvailInfo] -> NameSet
availsToNameSetWithSelectors [AvailInfo]
exports),
tcg_warns :: Warnings (GhcPass 'Renamed)
tcg_warns = forall pass. Warnings pass
warns
} forall a b. (a -> b) -> a -> b
$ do
TcGblEnv
tcg_env <- forall gbl lcl. TcRnIf gbl lcl gbl
getGblEnv
(Maybe
[(GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed)),
[AvailInfo])]
mb_lies, [AvailInfo]
_) <- Maybe (LocatedL [LIE GhcPs])
-> GlobalRdrEnv
-> ImportAvails
-> Module
-> TcRnIf
TcGblEnv
TcLclEnv
(Maybe [(LIE (GhcPass 'Renamed), [AvailInfo])], [AvailInfo])
exports_from_avail Maybe (LocatedL [LIE GhcPs])
mb_exports GlobalRdrEnv
rdr_env
(TcGblEnv -> ImportAvails
tcg_imports TcGblEnv
tcg_env) (TcGblEnv -> Module
tcg_semantic_mod TcGblEnv
tcg_env)
TcRn ()
failIfErrsM
forall gbl' lcl a gbl.
gbl' -> TcRnIf gbl' lcl a -> TcRnIf gbl lcl a
setGblEnv TcGblEnv
tcg_env { tcg_rn_exports :: Maybe [(LIE (GhcPass 'Renamed), [AvailInfo])]
tcg_rn_exports = Maybe
[(GenLocated
(SrcSpanAnn' (EpAnn AnnListItem)) (IE (GhcPass 'Renamed)),
[AvailInfo])]
mb_lies } forall a b. (a -> b) -> a -> b
$ do
TcGblEnv
tcg_env <- forall gbl lcl. TcRnIf gbl lcl gbl
getGblEnv
let home_unit :: HomeUnit
home_unit = HscEnv -> HomeUnit
hsc_home_unit HscEnv
hsc_env
[ModIface]
ext_ifaces <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM [(InstantiatedModule, ModIface)]
thinned_ifaces forall a b. (a -> b) -> a -> b
$ \((Module InstantiatedUnit
iuid ModuleName
_), ModIface
ireq_iface) ->
GenInstantiations UnitId
-> Maybe NameShape
-> ModIface
-> IOEnv (Env TcGblEnv TcLclEnv) ModIface
tcRnModIface (forall unit. GenInstantiatedUnit unit -> GenInstantiations unit
instUnitInsts InstantiatedUnit
iuid) (forall a. a -> Maybe a
Just NameShape
nsubst) ModIface
ireq_iface
ModIface
lcl_iface <- GenInstantiations UnitId
-> Maybe NameShape
-> ModIface
-> IOEnv (Env TcGblEnv TcLclEnv) ModIface
tcRnModIface (forall u. GenHomeUnit u -> GenInstantiations u
homeUnitInstantiations HomeUnit
home_unit) (forall a. a -> Maybe a
Just NameShape
nsubst) ModIface
lcl_iface0
let ifaces :: [ModIface]
ifaces = ModIface
lcl_iface forall a. a -> [a] -> [a]
: [ModIface]
ext_ifaces
let fix_env :: NameEnv FixItem
fix_env = forall a. [(Name, a)] -> NameEnv a
mkNameEnv [ (GlobalRdrElt -> Name
greMangledName GlobalRdrElt
rdr_elt, OccName -> Fixity -> FixItem
FixItem OccName
occ Fixity
f)
| (OccName
occ, Fixity
f) <- forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap forall (phase :: ModIfacePhase).
ModIface_ phase -> [(OccName, Fixity)]
mi_fixities [ModIface]
ifaces
, GlobalRdrElt
rdr_elt <- GlobalRdrEnv -> OccName -> [GlobalRdrElt]
lookupGlobalRdrEnv GlobalRdrEnv
rdr_env OccName
occ ]
let type_env_var :: KnotVars (IORef TypeEnv)
type_env_var = TcGblEnv -> KnotVars (IORef TypeEnv)
tcg_type_env_var TcGblEnv
tcg_env
(TypeEnv
type_env, [ModDetails]
detailss) <- forall a. IfG a -> TcRn a
initIfaceTcRn forall a b. (a -> b) -> a -> b
$
forall lcl.
Module
-> [ModIface]
-> KnotVars (IORef TypeEnv)
-> IfM lcl (TypeEnv, [ModDetails])
typecheckIfacesForMerging Module
inner_mod [ModIface]
ifaces KnotVars (IORef TypeEnv)
type_env_var
let infos :: [(ModIface, ModDetails)]
infos = forall a b. [a] -> [b] -> [(a, b)]
zip [ModIface]
ifaces [ModDetails]
detailss
Unit -> [TyCon] -> [LTyClDecl (GhcPass 'Renamed)] -> TcRn ()
checkSynCycles (HomeUnit -> Unit
homeUnitAsUnit HomeUnit
home_unit) (TypeEnv -> [TyCon]
typeEnvTyCons TypeEnv
type_env) []
forall gbl' lcl a gbl.
gbl' -> TcRnIf gbl' lcl a -> TcRnIf gbl lcl a
setGblEnv TcGblEnv
tcg_env {
tcg_tcs :: [TyCon]
tcg_tcs = TypeEnv -> [TyCon]
typeEnvTyCons TypeEnv
type_env,
tcg_patsyns :: [PatSyn]
tcg_patsyns = TypeEnv -> [PatSyn]
typeEnvPatSyns TypeEnv
type_env,
tcg_type_env :: TypeEnv
tcg_type_env = TypeEnv
type_env,
tcg_fix_env :: NameEnv FixItem
tcg_fix_env = NameEnv FixItem
fix_env
} forall a b. (a -> b) -> a -> b
$ do
TcGblEnv
tcg_env <- forall gbl lcl. TcRnIf gbl lcl gbl
getGblEnv
TcGblEnv
tcg_env <- (\TcGblEnv -> (ModIface, ModDetails) -> TcRn TcGblEnv
x -> forall (t :: * -> *) (m :: * -> *) b a.
(Foldable t, Monad m) =>
(b -> a -> m b) -> b -> t a -> m b
foldM TcGblEnv -> (ModIface, ModDetails) -> TcRn TcGblEnv
x TcGblEnv
tcg_env [(ModIface, ModDetails)]
infos)
forall a b. (a -> b) -> a -> b
$ \TcGblEnv
tcg_env (ModIface
iface, ModDetails
details) -> do
let check_export :: Name -> TcRn ()
check_export Name
name
| Just TyThing
sig_thing <- TypeEnv -> Name -> Maybe TyThing
lookupTypeEnv (ModDetails -> TypeEnv
md_types ModDetails
details) Name
name
= case TypeEnv -> Name -> Maybe TyThing
lookupTypeEnv TypeEnv
type_env (forall a. NamedThing a => a -> Name
getName TyThing
sig_thing) of
Just TyThing
thing -> ModIface -> TyThing -> TyThing -> TcRn ()
checkHsigDeclM ModIface
iface TyThing
sig_thing TyThing
thing
Maybe TyThing
Nothing -> forall a. String -> a
panic String
"mergeSignatures: check_export"
| Bool
otherwise
= forall (m :: * -> *) a. Monad m => a -> m a
return ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Name -> TcRn ()
check_export (forall a b. (a -> b) -> [a] -> [b]
map AvailInfo -> Name
availName [AvailInfo]
exports)
HscEnv
hsc_env <- forall gbl lcl. TcRnIf gbl lcl HscEnv
getTopEnv
let merge_inst :: ([ClsInst], InstEnv) -> ClsInst -> ([ClsInst], InstEnv)
merge_inst ([ClsInst]
insts, InstEnv
inst_env) ClsInst
inst
| InstEnv -> ClsInst -> Bool
memberInstEnv InstEnv
inst_env ClsInst
inst
= ([ClsInst]
insts, InstEnv
inst_env)
| Bool
otherwise
= (ClsInst
instforall a. a -> [a] -> [a]
:[ClsInst]
insts, InstEnv -> ClsInst -> InstEnv
extendInstEnv InstEnv
inst_env ClsInst
inst)
([ClsInst]
insts, InstEnv
inst_env) = forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' ([ClsInst], InstEnv) -> ClsInst -> ([ClsInst], InstEnv)
merge_inst
(TcGblEnv -> [ClsInst]
tcg_insts TcGblEnv
tcg_env, TcGblEnv -> InstEnv
tcg_inst_env TcGblEnv
tcg_env)
(InstEnv -> [ClsInst]
instEnvElts forall a b. (a -> b) -> a -> b
$ ModDetails -> InstEnv
md_insts ModDetails
details)
iface' :: ModIface
iface' = ModIface
iface { mi_final_exts :: IfaceBackendExts 'ModIfaceFinal
mi_final_exts = (forall (phase :: ModIfacePhase).
ModIface_ phase -> IfaceBackendExts phase
mi_final_exts ModIface
iface){ mi_orphan :: Bool
mi_orphan = Bool
False, mi_finsts :: Bool
mi_finsts = Bool
False } }
home_unit :: HomeUnit
home_unit = HscEnv -> HomeUnit
hsc_home_unit HscEnv
hsc_env
other_home_units :: Set UnitId
other_home_units = HscEnv -> Set UnitId
hsc_all_home_unit_ids HscEnv
hsc_env
avails :: ImportAvails
avails = ImportAvails -> ImportAvails -> ImportAvails
plusImportAvails (TcGblEnv -> ImportAvails
tcg_imports TcGblEnv
tcg_env) forall a b. (a -> b) -> a -> b
$
HomeUnit
-> Set UnitId
-> ModIface
-> Bool
-> IsBootInterface
-> ImportedBy
-> ImportAvails
calculateAvails HomeUnit
home_unit Set UnitId
other_home_units ModIface
iface' Bool
False IsBootInterface
NotBoot ImportedBy
ImportedBySystem
forall (m :: * -> *) a. Monad m => a -> m a
return TcGblEnv
tcg_env {
tcg_inst_env :: InstEnv
tcg_inst_env = InstEnv
inst_env,
tcg_insts :: [ClsInst]
tcg_insts = [ClsInst]
insts,
tcg_imports :: ImportAvails
tcg_imports = ImportAvails
avails,
tcg_merged :: [(Module, Fingerprint)]
tcg_merged =
if Module
outer_mod forall a. Eq a => a -> a -> Bool
== forall (phase :: ModIfacePhase). ModIface_ phase -> Module
mi_module ModIface
iface
then TcGblEnv -> [(Module, Fingerprint)]
tcg_merged TcGblEnv
tcg_env
else (forall (phase :: ModIfacePhase). ModIface_ phase -> Module
mi_module ModIface
iface, ModIfaceBackend -> Fingerprint
mi_mod_hash (forall (phase :: ModIfacePhase).
ModIface_ phase -> IfaceBackendExts phase
mi_final_exts ModIface
iface)) forall a. a -> [a] -> [a]
: TcGblEnv -> [(Module, Fingerprint)]
tcg_merged TcGblEnv
tcg_env
}
[(Id, ClsInst)]
dfun_insts <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM (TcGblEnv -> [ClsInst]
tcg_insts TcGblEnv
tcg_env) forall a b. (a -> b) -> a -> b
$ \ClsInst
inst -> do
Name
n <- Class -> [Kind] -> SrcSpan -> TcM Name
newDFunName (ClsInst -> Class
is_cls ClsInst
inst) (ClsInst -> [Kind]
is_tys ClsInst
inst) (Name -> SrcSpan
nameSrcSpan (ClsInst -> Name
is_dfun_name ClsInst
inst))
let dfun :: Id
dfun = Id -> Name -> Id
setVarName (ClsInst -> Id
is_dfun ClsInst
inst) Name
n
forall (m :: * -> *) a. Monad m => a -> m a
return (Id
dfun, ClsInst
inst { is_dfun_name :: Name
is_dfun_name = Name
n, is_dfun :: Id
is_dfun = Id
dfun })
TcGblEnv
tcg_env <- forall (m :: * -> *) a. Monad m => a -> m a
return TcGblEnv
tcg_env {
tcg_insts :: [ClsInst]
tcg_insts = forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> b
snd [(Id, ClsInst)]
dfun_insts,
tcg_type_env :: TypeEnv
tcg_type_env = TypeEnv -> [Id] -> TypeEnv
extendTypeEnvWithIds (TcGblEnv -> TypeEnv
tcg_type_env TcGblEnv
tcg_env) (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(Id, ClsInst)]
dfun_insts)
}
[String] -> TcRn ()
addDependentFiles [String]
src_files
forall (m :: * -> *) a. Monad m => a -> m a
return TcGblEnv
tcg_env
tcRnInstantiateSignature ::
HscEnv -> Module -> RealSrcSpan ->
IO (Messages TcRnMessage, Maybe TcGblEnv)
tcRnInstantiateSignature :: HscEnv
-> Module
-> RealSrcSpan
-> IO (Messages TcRnMessage, Maybe TcGblEnv)
tcRnInstantiateSignature HscEnv
hsc_env Module
this_mod RealSrcSpan
real_loc =
forall (m :: * -> *) a.
MonadIO m =>
Logger -> SDoc -> (a -> ()) -> m a -> m a
withTiming Logger
logger
(String -> SDoc
text String
"Signature instantiation"SDoc -> SDoc -> SDoc
<+>SDoc -> SDoc
brackets (forall a. Outputable a => a -> SDoc
ppr Module
this_mod))
(forall a b. a -> b -> a
const ()) forall a b. (a -> b) -> a -> b
$
forall r.
HscEnv
-> HscSource
-> Bool
-> Module
-> RealSrcSpan
-> TcM r
-> IO (Messages TcRnMessage, Maybe r)
initTc HscEnv
hsc_env HscSource
HsigFile Bool
False Module
this_mod RealSrcSpan
real_loc forall a b. (a -> b) -> a -> b
$ TcRn TcGblEnv
instantiateSignature
where
logger :: Logger
logger = HscEnv -> Logger
hsc_logger HscEnv
hsc_env
exportOccs :: [AvailInfo] -> [OccName]
exportOccs :: [AvailInfo] -> [OccName]
exportOccs = forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (forall a b. (a -> b) -> [a] -> [b]
map forall name. HasOccName name => name -> OccName
occName forall b c a. (b -> c) -> (a -> b) -> a -> c
. AvailInfo -> [Name]
availNames)
impl_msg :: UnitState -> Module -> InstantiatedModule -> SDoc
impl_msg :: UnitState -> Module -> InstantiatedModule -> SDoc
impl_msg UnitState
unit_state Module
impl_mod (Module InstantiatedUnit
req_uid ModuleName
req_mod_name)
= UnitState -> SDoc -> SDoc
pprWithUnitState UnitState
unit_state forall a b. (a -> b) -> a -> b
$
String -> SDoc
text String
"while checking that" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr Module
impl_mod SDoc -> SDoc -> SDoc
<+>
String -> SDoc
text String
"implements signature" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr ModuleName
req_mod_name SDoc -> SDoc -> SDoc
<+>
String -> SDoc
text String
"in" SDoc -> SDoc -> SDoc
<+> forall a. Outputable a => a -> SDoc
ppr InstantiatedUnit
req_uid
checkImplements :: Module -> InstantiatedModule -> TcRn TcGblEnv
checkImplements :: Module -> InstantiatedModule -> TcRn TcGblEnv
checkImplements Module
impl_mod req_mod :: InstantiatedModule
req_mod@(Module InstantiatedUnit
uid ModuleName
mod_name) = do
HscEnv
hsc_env <- forall gbl lcl. TcRnIf gbl lcl HscEnv
getTopEnv
let unit_state :: UnitState
unit_state = HasDebugCallStack => HscEnv -> UnitState
hsc_units HscEnv
hsc_env
home_unit :: HomeUnit
home_unit = HscEnv -> HomeUnit
hsc_home_unit HscEnv
hsc_env
other_home_units :: Set UnitId
other_home_units = HscEnv -> Set UnitId
hsc_all_home_unit_ids HscEnv
hsc_env
forall a. SDoc -> TcM a -> TcM a
addErrCtxt (UnitState -> Module -> InstantiatedModule -> SDoc
impl_msg UnitState
unit_state Module
impl_mod InstantiatedModule
req_mod) forall a b. (a -> b) -> a -> b
$ do
let insts :: GenInstantiations UnitId
insts = forall unit. GenInstantiatedUnit unit -> GenInstantiations unit
instUnitInsts InstantiatedUnit
uid
ModIface
impl_iface <- forall a. IfG a -> TcRn a
initIfaceTcRn forall a b. (a -> b) -> a -> b
$
forall lcl. SDoc -> Module -> IfM lcl ModIface
loadSysInterface (String -> SDoc
text String
"checkImplements 1") Module
impl_mod
let impl_gr :: GlobalRdrEnv
impl_gr = [GlobalRdrElt] -> GlobalRdrEnv
mkGlobalRdrEnv
(Maybe ImportSpec -> [AvailInfo] -> [GlobalRdrElt]
gresFromAvails forall a. Maybe a
Nothing (forall (phase :: ModIfacePhase). ModIface_ phase -> [AvailInfo]
mi_exports ModIface
impl_iface))
nsubst :: NameShape
nsubst = ModuleName -> [AvailInfo] -> NameShape
mkNameShape (forall unit. GenModule unit -> ModuleName
moduleName Module
impl_mod) (forall (phase :: ModIfacePhase). ModIface_ phase -> [AvailInfo]
mi_exports ModIface
impl_iface)
SDoc -> [Module] -> TcRn ()
loadModuleInterfaces (String -> SDoc
text String
"Loading orphan modules (from implementor of hsig)")
(Dependencies -> [Module]
dep_orphs (forall (phase :: ModIfacePhase). ModIface_ phase -> Dependencies
mi_deps ModIface
impl_iface))
let avails :: ImportAvails
avails = HomeUnit
-> Set UnitId
-> ModIface
-> Bool
-> IsBootInterface
-> ImportedBy
-> ImportAvails
calculateAvails HomeUnit
home_unit Set UnitId
other_home_units
ModIface
impl_iface Bool
False IsBootInterface
NotBoot ImportedBy
ImportedBySystem
fix_env :: NameEnv FixItem
fix_env = forall a. [(Name, a)] -> NameEnv a
mkNameEnv [ (GlobalRdrElt -> Name
greMangledName GlobalRdrElt
rdr_elt, OccName -> Fixity -> FixItem
FixItem OccName
occ Fixity
f)
| (OccName
occ, Fixity
f) <- forall (phase :: ModIfacePhase).
ModIface_ phase -> [(OccName, Fixity)]
mi_fixities ModIface
impl_iface
, GlobalRdrElt
rdr_elt <- GlobalRdrEnv -> OccName -> [GlobalRdrElt]
lookupGlobalRdrEnv GlobalRdrEnv
impl_gr OccName
occ ]
forall gbl lcl a.
(gbl -> gbl) -> TcRnIf gbl lcl a -> TcRnIf gbl lcl a
updGblEnv (\TcGblEnv
tcg_env -> TcGblEnv
tcg_env {
tcg_rdr_env :: GlobalRdrEnv
tcg_rdr_env = TcGblEnv -> GlobalRdrEnv
tcg_rdr_env TcGblEnv
tcg_env GlobalRdrEnv -> GlobalRdrEnv -> GlobalRdrEnv
`plusGlobalRdrEnv` GlobalRdrEnv
impl_gr,
tcg_imports :: ImportAvails
tcg_imports = TcGblEnv -> ImportAvails
tcg_imports TcGblEnv
tcg_env ImportAvails -> ImportAvails -> ImportAvails
`plusImportAvails` ImportAvails
avails,
tcg_fix_env :: NameEnv FixItem
tcg_fix_env = NameEnv FixItem
fix_env
}) forall a b. (a -> b) -> a -> b
$ do
let sig_mod :: Module
sig_mod = forall u. u -> ModuleName -> GenModule u
mkModule (forall uid. GenInstantiatedUnit uid -> GenUnit uid
VirtUnit InstantiatedUnit
uid) ModuleName
mod_name
isig_mod :: InstalledModule
isig_mod = forall a b. (a, b) -> a
fst (Module -> (InstalledModule, Maybe InstantiatedModule)
getModuleInstantiation Module
sig_mod)
HscEnv
hsc_env <- forall gbl lcl. TcRnIf gbl lcl HscEnv
getTopEnv
MaybeErr SDoc (ModIface, String)
mb_isig_iface <- forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO forall a b. (a -> b) -> a -> b
$ HscEnv
-> SDoc
-> InstalledModule
-> Module
-> IsBootInterface
-> IO (MaybeErr SDoc (ModIface, String))
findAndReadIface HscEnv
hsc_env
(String -> SDoc
text String
"checkImplements 2")
InstalledModule
isig_mod Module
sig_mod IsBootInterface
NotBoot
ModIface
isig_iface <- case MaybeErr SDoc (ModIface, String)
mb_isig_iface of
Succeeded (ModIface
iface, String
_) -> forall (m :: * -> *) a. Monad m => a -> m a
return ModIface
iface
Failed SDoc
err -> forall a. TcRnMessage -> TcM a
failWithTc forall a b. (a -> b) -> a -> b
$ forall a. (Diagnostic a, Typeable a) => a -> TcRnMessage
TcRnUnknownMessage forall a b. (a -> b) -> a -> b
$ [GhcHint] -> SDoc -> DiagnosticMessage
mkPlainError [GhcHint]
noHints forall a b. (a -> b) -> a -> b
$
SDoc -> Int -> SDoc -> SDoc
hang (String -> SDoc
text String
"Could not find hi interface for signature" SDoc -> SDoc -> SDoc
<+>
SDoc -> SDoc
quotes (forall a. Outputable a => a -> SDoc
ppr InstalledModule
isig_mod) SDoc -> SDoc -> SDoc
<> SDoc
colon) Int
4 SDoc
err
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ ([AvailInfo] -> [OccName]
exportOccs (forall (phase :: ModIfacePhase). ModIface_ phase -> [AvailInfo]
mi_exports ModIface
isig_iface)) forall a b. (a -> b) -> a -> b
$ \OccName
occ ->
case GlobalRdrEnv -> OccName -> [GlobalRdrElt]
lookupGlobalRdrEnv GlobalRdrEnv
impl_gr OccName
occ of
[] -> TcRnMessage -> TcRn ()
addErr forall a b. (a -> b) -> a -> b
$ forall a. (Diagnostic a, Typeable a) => a -> TcRnMessage
TcRnUnknownMessage forall a b. (a -> b) -> a -> b
$ [GhcHint] -> SDoc -> DiagnosticMessage
mkPlainError [GhcHint]
noHints forall a b. (a -> b) -> a -> b
$
SDoc -> SDoc
quotes (forall a. Outputable a => a -> SDoc
ppr OccName
occ)
SDoc -> SDoc -> SDoc
<+> String -> SDoc
text String
"is exported by the hsig file, but not exported by the implementing module"
SDoc -> SDoc -> SDoc
<+> SDoc -> SDoc
quotes (UnitState -> SDoc -> SDoc
pprWithUnitState UnitState
unit_state forall a b. (a -> b) -> a -> b
$ forall a. Outputable a => a -> SDoc
ppr Module
impl_mod)
[GlobalRdrElt]
_ -> forall (m :: * -> *) a. Monad m => a -> m a
return ()
TcRn ()
failIfErrsM
ModIface
sig_iface <- GenInstantiations UnitId
-> Maybe NameShape
-> ModIface
-> IOEnv (Env TcGblEnv TcLclEnv) ModIface
tcRnModIface GenInstantiations UnitId
insts (forall a. a -> Maybe a
Just NameShape
nsubst) ModIface
isig_iface
ModDetails
sig_details <- forall a. IfG a -> TcRn a
initIfaceTcRn forall a b. (a -> b) -> a -> b
$ forall lcl. NameShape -> ModIface -> IfM lcl ModDetails
typecheckIfaceForInstantiate NameShape
nsubst ModIface
sig_iface
TcGblEnv
tcg_env <- forall gbl lcl. TcRnIf gbl lcl gbl
getGblEnv
TcGblEnv -> GlobalRdrEnv -> ModIface -> ModDetails -> TcRn ()
checkHsigIface TcGblEnv
tcg_env GlobalRdrEnv
impl_gr ModIface
sig_iface ModDetails
sig_details
forall (m :: * -> *) a. Monad m => a -> m a
return TcGblEnv
tcg_env {
tcg_exports :: [AvailInfo]
tcg_exports = forall (phase :: ModIfacePhase). ModIface_ phase -> [AvailInfo]
mi_exports ModIface
sig_iface
}
instantiateSignature :: TcRn TcGblEnv
instantiateSignature :: TcRn TcGblEnv
instantiateSignature = do
HscEnv
hsc_env <- forall gbl lcl. TcRnIf gbl lcl HscEnv
getTopEnv
TcGblEnv
tcg_env <- forall gbl lcl. TcRnIf gbl lcl gbl
getGblEnv
let outer_mod :: Module
outer_mod = TcGblEnv -> Module
tcg_mod TcGblEnv
tcg_env
inner_mod :: Module
inner_mod = TcGblEnv -> Module
tcg_semantic_mod TcGblEnv
tcg_env
home_unit :: HomeUnit
home_unit = HscEnv -> HomeUnit
hsc_home_unit HscEnv
hsc_env
forall (m :: * -> *). (HasCallStack, Applicative m) => Bool -> m ()
massert (HomeUnit -> Module -> Bool
isHomeModule HomeUnit
home_unit Module
outer_mod )
forall (m :: * -> *). (HasCallStack, Applicative m) => Bool -> m ()
massert (forall u. GenHomeUnit u -> Bool
isHomeUnitInstantiating HomeUnit
home_unit)
let uid :: UnitId
uid = HomeUnit -> UnitId
homeUnitInstanceOf HomeUnit
home_unit
Module
inner_mod Module -> InstantiatedModule -> TcRn TcGblEnv
`checkImplements`
forall u. u -> ModuleName -> GenModule u
Module
(forall u.
IsUnitId u =>
u -> GenInstantiations u -> GenInstantiatedUnit u
mkInstantiatedUnit UnitId
uid (forall u. GenHomeUnit u -> GenInstantiations u
homeUnitInstantiations HomeUnit
home_unit))
(forall unit. GenModule unit -> ModuleName
moduleName Module
outer_mod)