Small refactoring
[ghc-hetmet.git] / compiler / rename / RnNames.lhs
index 9d2f542..b5ed7d0 100644 (file)
@@ -1061,10 +1061,13 @@ check_occs ie occs names
           Nothing -> return (extendOccEnv occs name_occ (name, ie))
 
           Just (name', ie')
-            | name == name'    -- Duplicate export
-            ->  do { warn_dup_exports <- doptM Opt_WarnDuplicateExports ;
-                     warnIf warn_dup_exports (dupExportWarn name_occ ie ie') ;
-                     return occs }
+            | name == name'   -- Duplicate export
+            -- But we don't want to warn if the same thing is exported
+            -- by two different module exports. See ticket #4478.
+            -> do unless (diffModules ie ie') $ do
+                      warn_dup_exports <- doptM Opt_WarnDuplicateExports
+                      warnIf warn_dup_exports (dupExportWarn name_occ ie ie')
+                  return occs
 
             | otherwise    -- Same occ name but different names: an error
             ->  do { global_env <- getGlobalRdrEnv ;
@@ -1072,6 +1075,9 @@ check_occs ie occs names
                      return occs }
       where
         name_occ = nameOccName name
+        -- True if the two IE RdrName are different module exports.
+        diffModules (IEModuleContents n1) (IEModuleContents n2) = n1 /= n2
+        diffModules _                     _                     = False
 \end{code}
 
 %*********************************************************