\begin{code}
isImplicitId :: Id -> Bool
isImplicitId id
- = ASSERT2( not (omit && nameIsLocallyDefined (idName id)
- && idTyGenInfo id /= TyGenNever),
- ppr id )
- -- mustn't omit type signature for a name whose type might change!
- omit
- where
- omit = isImplicitId' id
-
-isImplicitId' id
= case idFlavour id of
RecordSelId _ -> True -- Includes dictionary selectors
PrimOpId _ -> True
-- remember that all type and class decls appear in the interface file.
-- The dfun id must *not* be omitted, because it carries version info for
-- the instance decl
-
- ConstantId -> False -- Ordinary Ids
- DictFunId -> False
-
- ExportedId -> False -- I don't think these happen
- VanillaId -> False -- ditto
- SpecPragmaId -> False -- ditto
+ other -> False
\end{code}
\begin{code}
\begin{code}
vanillaIdInfo :: IdInfo
-vanillaIdInfo = mkIdInfo VanillaId
+ -- Used for locally-defined Ids
+ -- We are going to calculate correct CAF information at the end
+vanillaIdInfo = mkIdInfo VanillaId NoCafRefs
constantIdInfo :: IdInfo
-constantIdInfo = mkIdInfo ConstantId
+ -- Used for imported Ids
+ -- The default is that they *do* have CAFs; an interface-file pragma
+ -- may say "oh no it doesn't", but in the absence of such a pragma
+ -- we'd better assume it does
+constantIdInfo = mkIdInfo ConstantId MayHaveCafRefs
mkIdInfo :: IdFlavour -> IdInfo
-mkIdInfo flv = IdInfo {
- flavourInfo = flv,
- arityInfo = UnknownArity,
- demandInfo = wwLazy,
- specInfo = emptyCoreRules,
- tyGenInfo = noTyGenInfo,
- workerInfo = NoWorker,
- strictnessInfo = NoStrictnessInfo,
- unfoldingInfo = noUnfolding,
- cafInfo = NoCafRefs,
- cprInfo = NoCPRInfo,
- lbvarInfo = NoLBVarInfo,
- inlinePragInfo = NoInlinePragInfo,
- occInfo = NoOccInfo
+mkIdInfo flv caf
+ = IdInfo {
+ flavourInfo = flv,
+ arityInfo = UnknownArity,
+ demandInfo = wwLazy,
+ specInfo = emptyCoreRules,
+ tyGenInfo = noTyGenInfo,
+ workerInfo = NoWorker,
+ strictnessInfo = NoStrictnessInfo,
+ unfoldingInfo = noUnfolding,
+ cafInfo = caf
+ cprInfo = NoCPRInfo,
+ lbvarInfo = NoLBVarInfo,
+ inlinePragInfo = NoInlinePragInfo,
+ occInfo = NoOccInfo
}
\end{code}
that all Ids are unique, rather than the weaker guarantee of
no clashes which the simplifier provides.
- - Give the Id its final IdInfo; in ptic,
+ - Give each dynamic CCall occurrence a fresh unique; this is
+ rather like the cloning step above.
+
+ - Give the Id its UTTERLY FINAL IdInfo; in ptic,
* Its flavour becomes ConstantId, reflecting the fact that
from now on we regard it as a constant, not local, Id
+
* its unfolding, if it should have one
+
+ * its arity, computed from the number of visible lambdas
+
+ * its CAF info, computed from what is free in its RHS
+
Finally, substitute these new top-level binders consistently
throughout, including in unfoldings. We also tidy binders in
-- The Id must be returned without a data dependency on maybe_id
where
new_info = case tcLookupRecId_maybe env (idName id) of
- Nothing -> constantIdInfo
+ Nothing -> pprTrace "tcAddIdInfo" (ppr id) constantIdInfo
Just imported_id -> idInfo imported_id
-- ToDo: could check that types are the same