diff --git a/ghc/compiler/basicTypes/Id.lhs b/ghc/compiler/basicTypes/Id.lhs index 1c8e02619761e2b76e32fcac0e02f1bdc2503cb4..aa086a19e534243d7fc052b05ba3428e5ddb7a3b 100644 --- a/ghc/compiler/basicTypes/Id.lhs +++ b/ghc/compiler/basicTypes/Id.lhs @@ -22,6 +22,7 @@ module Id ( -- Predicates omitIfaceSigForId, + exportWithOrigOccName, externallyVisibleId, idFreeTyVars, @@ -248,6 +249,12 @@ omitIfaceSigForId id -- the instance decl other -> False -- Don't omit! + +-- Certain names must be exported with their original occ names, because +-- these names are bound by either a class declaration or a data declaration +-- or an explicit user export. +exportWithOrigOccName :: Id -> Bool +exportWithOrigOccName id = omitIfaceSigForId id || isUserExportedId id \end{code} diff --git a/ghc/compiler/coreSyn/CoreTidy.lhs b/ghc/compiler/coreSyn/CoreTidy.lhs index 27843e820bad0ba9b29b22ad8edd3bb174b112bb..51a5175dc5e86535dd69dbccce04cf2fe910a82e 100644 --- a/ghc/compiler/coreSyn/CoreTidy.lhs +++ b/ghc/compiler/coreSyn/CoreTidy.lhs @@ -21,7 +21,7 @@ import VarEnv import VarSet import Var ( Id, IdOrTyVar ) import Id ( idType, idInfo, idName, - mkVanillaId, mkId, isUserExportedId, + mkVanillaId, mkId, exportWithOrigOccName, getIdStrictness, setIdStrictness, getIdDemandInfo, setIdDemandInfo, ) @@ -94,7 +94,7 @@ tidyCorePgm us module_name binds_in rules -- decl. tidyTopId then does a no-op on exported binders. init_tidy_env = (initTidyOccEnv avoids, emptyVarEnv) avoids = [getOccName bndr | bndr <- bindersOfBinds binds_in, - isUserExportedId bndr] + exportWithOrigOccName bndr] tidyBind :: Maybe Module -- (Just m) for top level, Nothing for nested -> TidyEnv @@ -207,8 +207,8 @@ tidyTopId :: Module -> TidyEnv -> TidyEnv -> Id -> (TidyEnv, Id) tidyTopId mod env@(tidy_env, var_env) env_idinfo id = -- Top level variables let - (tidy_env', name') | isUserExportedId id = (tidy_env, idName id) - | otherwise = tidyTopName mod tidy_env (idName id) + (tidy_env', name') | exportWithOrigOccName id = (tidy_env, idName id) + | otherwise = tidyTopName mod tidy_env (idName id) ty' = tidyTopType (idType id) idinfo' = tidyIdInfo env_idinfo (idInfo id) id' = mkId name' ty' idinfo'