Fix import error with -XPackageImports when the module has a duplicate name
authorEugene Akentyev <ak3ntev@gmail.com>
Mon, 24 Jul 2017 23:53:57 +0000 (19:53 -0400)
committerBen Gamari <ben@smart-cactus.org>
Tue, 25 Jul 2017 01:06:13 +0000 (21:06 -0400)
Reviewers: austin, bgamari, mpickering

Reviewed By: bgamari

Subscribers: mpickering, rwbarton, thomie

GHC Trac Issues: #13168

Differential Revision: https://phabricator.haskell.org/D3738

compiler/typecheck/TcRnDriver.hs
testsuite/tests/typecheck/T13168/all.T

index c9c259e..8a6d72e 100644 (file)
@@ -1777,14 +1777,19 @@ runTcInteractive hsc_env thing_inside
                       vcat (map ppr [ local_gres | gres <- occEnvElts (ic_rn_gbl_env icxt)
                                                  , let local_gres = filter isLocalGRE gres
                                                  , not (null local_gres) ]) ]
-       ; let getOrphans m = fmap (\iface -> mi_module iface
+
+       ; let getOrphans m mb_pkg = fmap (\iface -> mi_module iface
                                           : dep_orphs (mi_deps iface))
                                  (loadSrcInterface (text "runTcInteractive") m
-                                                   False Nothing)
+                                                   False mb_pkg)
+
        ; orphs <- fmap concat . forM (ic_imports icxt) $ \i ->
             case i of
-                IIModule n -> getOrphans n
-                IIDecl i -> getOrphans (unLoc (ideclName i))
+                IIModule n -> getOrphans n Nothing
+                IIDecl i ->
+                  let mb_pkg = sl_fs <$> ideclPkgQual i in
+                  getOrphans (unLoc (ideclName i)) mb_pkg
+
        ; let imports = emptyImportAvails {
                             imp_orphs = orphs
                         }
index 8552366..43a5e1b 100644 (file)
@@ -1,4 +1,4 @@
 test('T13168',
-     [extra_files(['package1', 'package2', 'Setup.hs']), expect_broken(13168)],
+     extra_files(['package1', 'package2', 'Setup.hs']),
      run_command,
      ['$MAKE -s --no-print-directory T13168'])