[project @ 2005-02-23 12:18:29 by simonmar]
authorsimonmar <unknown>
Wed, 23 Feb 2005 12:18:29 +0000 (12:18 +0000)
committersimonmar <unknown>
Wed, 23 Feb 2005 12:18:29 +0000 (12:18 +0000)
fix for findPackageModule: if we find the module in the cache, check
that it actually is a package module before returning it.

ghc/compiler/main/Finder.lhs

index 260ee07..a260f3e 100644 (file)
@@ -108,9 +108,10 @@ type LocalFindResult = MaybeErr [FilePath] FinderCacheEntry
        -- return a more informative type; it's munged into
        -- the external FindResult by 'cached'
 
-cached :: (DynFlags -> Module -> IO LocalFindResult)
+cached :: Bool
+       -> (DynFlags -> Module -> IO LocalFindResult)
        -> DynFlags -> Module -> Bool -> IO FindResult
-cached wrapped_fn dflags name explicit 
+cached home_allowed wrapped_fn dflags name explicit 
   = do {       -- First try the cache
          mb_entry <- lookupFinderCache name
        ; case mb_entry of {
@@ -128,7 +129,9 @@ cached wrapped_fn dflags name explicit
        -- We've found the module, so the remaining question is
        -- whether it's visible or not
     found :: FinderCacheEntry -> FindResult
-    found (loc, Nothing)               = Found loc HomePackage
+    found (loc, Nothing)
+       | home_allowed  = Found loc HomePackage
+       | otherwise     = NotFound []
     found (loc, Just (pkg, exposed_mod))
        | explicit && not exposed_mod   = ModuleHidden pkg_name
        | explicit && not (exposed pkg) = PackageHidden pkg_name
@@ -145,10 +148,10 @@ addHomeModuleToFinder mod loc = addToFinderCache mod (loc, Nothing)
 
 
 findModule :: DynFlags -> Module -> Bool -> IO FindResult
-findModule = cached findModule' 
+findModule = cached True findModule' 
   
 findPackageModule :: DynFlags -> Module -> Bool -> IO FindResult
-findPackageModule = cached findPackageModule'
+findPackageModule = cached False findPackageModule'
 
 -- -----------------------------------------------------------------------------
 --     The internal workers