Skip to content

Commit 026d0ce

Browse files
wz1000michaelpj
andauthored
FindImports: ThisPkg means some home unit, not "this" unit (#4284)
Co-authored-by: Michael Peyton Jones <[email protected]>
1 parent 52c953c commit 026d0ce

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

ghcide/src/Development/IDE/Import/FindImports.hs

+7-3
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,17 @@ locateModule
131131
-> m (Either [FileDiagnostic] Import)
132132
locateModule env comp_info exts targetFor modName mbPkgName isSource = do
133133
case mbPkgName of
134-
-- "this" means that we should only look in the current package
135134
#if MIN_VERSION_ghc(9,3,0)
136-
ThisPkg _ -> do
135+
-- 'ThisPkg' just means some home module, not the current unit
136+
ThisPkg uid
137+
| Just (dirs, reexports) <- lookup uid import_paths
138+
-> lookupLocal uid dirs reexports
139+
| otherwise -> return $ Left $ notFoundErr env modName $ LookupNotFound []
137140
#else
141+
-- "this" means that we should only look in the current package
138142
Just "this" -> do
139-
#endif
140143
lookupLocal (homeUnitId_ dflags) (importPaths dflags) S.empty
144+
#endif
141145
-- if a package name is given we only go look for a package
142146
#if MIN_VERSION_ghc(9,3,0)
143147
OtherPkg uid

ghcide/test/data/multi-unit/b-1.0.0-inplace

+1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ a-1.0.0-inplace
1616
-package
1717
base
1818
-XHaskell98
19+
-XPackageImports
1920
B

ghcide/test/data/multi-unit/b/B.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module B(module B) where
2-
import A
2+
import "a" A
33
qux = foo

0 commit comments

Comments
 (0)