diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/iface/LoadIface.hs | 18 | ||||
-rw-r--r-- | compiler/utils/Outputable.hs | 8 |
2 files changed, 19 insertions, 7 deletions
diff --git a/compiler/iface/LoadIface.hs b/compiler/iface/LoadIface.hs index 4524402985..34ba1cbb7a 100644 --- a/compiler/iface/LoadIface.hs +++ b/compiler/iface/LoadIface.hs @@ -1047,6 +1047,15 @@ ifaceStats eps Printing interfaces * * ************************************************************************ + +Note [Name qualification with --show-iface] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In order to disambiguate between identifiers from different modules, we qualify +all names that don't originate in the current module. In order to keep visual +noise as low as possible, we keep local names unqualified. + +For some background on this choice see trac #15269. -} -- | Read binary interface, and print it out @@ -1057,8 +1066,15 @@ showIface hsc_env filename = do iface <- initTcRnIf 's' hsc_env () () $ readBinIface IgnoreHiWay TraceBinIFaceReading filename let dflags = hsc_dflags hsc_env + -- See Note [Name qualification with --show-iface] + qualifyImportedNames mod _ + | mod == mi_module iface = NameUnqual + | otherwise = NameNotInScope1 + print_unqual = QueryQualify qualifyImportedNames + neverQualifyModules + neverQualifyPackages putLogMsg dflags NoReason SevDump noSrcSpan - (defaultDumpStyle dflags) (pprModIface iface) + (mkDumpStyle dflags print_unqual) (pprModIface iface) -- Show a ModIface but don't display details; suitable for ModIfaces stored in -- the EPT. diff --git a/compiler/utils/Outputable.hs b/compiler/utils/Outputable.hs index 4df9adfe84..929c7f3d58 100644 --- a/compiler/utils/Outputable.hs +++ b/compiler/utils/Outputable.hs @@ -181,12 +181,8 @@ data PrintUnqualified = QueryQualify { queryQualifyPackage :: QueryQualifyPackage } --- | given an /original/ name, this function tells you which module --- name it should be qualified with when printing for the user, if --- any. For example, given @Control.Exception.catch@, which is in scope --- as @Exception.catch@, this function will return @Just "Exception"@. --- Note that the return value is a ModuleName, not a Module, because --- in source code, names are qualified by ModuleNames. +-- | Given a `Name`'s `Module` and `OccName`, decide whether and how to qualify +-- it. type QueryQualifyName = Module -> OccName -> QualifyName -- | For a given module, we need to know whether to print it with |