summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/main/GhcMake.hs2
-rw-r--r--compiler/main/HscTypes.hs5
-rw-r--r--testsuite/tests/ghc-api/target-contents/TargetContents.hs3
-rw-r--r--testsuite/tests/ghc-api/target-contents/TargetContents.stderr22
4 files changed, 14 insertions, 18 deletions
diff --git a/compiler/main/GhcMake.hs b/compiler/main/GhcMake.hs
index 5c76f2856d..9a4911f2c1 100644
--- a/compiler/main/GhcMake.hs
+++ b/compiler/main/GhcMake.hs
@@ -1968,7 +1968,7 @@ downsweep hsc_env old_summaries excl_mods allow_dup_roots
getRootSummary :: Target -> IO (Either ErrMsg ModSummary)
getRootSummary (Target (TargetFile file mb_phase) obj_allowed maybe_buf)
= do exists <- liftIO $ doesFileExist file
- if exists
+ if exists || isJust maybe_buf
then Right `fmap` summariseFile hsc_env old_summaries file mb_phase
obj_allowed maybe_buf
else return $ Left $ mkPlainErrMsg dflags noSrcSpan $
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 88edccf5bc..b29143a45b 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -505,6 +505,11 @@ data Target
--
-- Since GHC version 8.10 modules which require preprocessors such as
-- Literate Haskell or CPP to run are also supported.
+ --
+ -- If a corresponding source file does not exist on disk this will
+ -- result in a 'SourceError' exception if @targetId = TargetModule _@
+ -- is used. However together with @targetId = TargetFile _@ GHC will
+ -- not complain about the file missing.
}
data TargetId
diff --git a/testsuite/tests/ghc-api/target-contents/TargetContents.hs b/testsuite/tests/ghc-api/target-contents/TargetContents.hs
index db02dbde2b..eaa30697f8 100644
--- a/testsuite/tests/ghc-api/target-contents/TargetContents.hs
+++ b/testsuite/tests/ghc-api/target-contents/TargetContents.hs
@@ -90,8 +90,7 @@ main = do
data Sync
= OnDisk -- | Write generated module to disk
- | InMemory -- | Only fill targetContents, place an empty dummy module
- -- on disk though to make Finder shut up though.
+ | InMemory -- | Only fill in targetContents.
ppSync OnDisk = "D"
ppSync InMemory = "M"
diff --git a/testsuite/tests/ghc-api/target-contents/TargetContents.stderr b/testsuite/tests/ghc-api/target-contents/TargetContents.stderr
index b0a363c1e5..2743f5135e 100644
--- a/testsuite/tests/ghc-api/target-contents/TargetContents.stderr
+++ b/testsuite/tests/ghc-api/target-contents/TargetContents.stderr
@@ -3,8 +3,6 @@
A.hs:3:5: error: Variable not in scope: z
== CPP_D
== CPP_M
-can't find file: A.hs
-
== Dep_DD_AB
== Dep_Error_DD_AB
@@ -13,33 +11,27 @@ B.hs:3:5: error: Variable not in scope: z
B.hs:3:5: error: Variable not in scope: z
== Dep_MM_AB
-can't find file: A.hs
-can't find file: B.hs
-
== Dep_Error_MM_AB
-can't find file: A.hs
-can't find file: B.hs
+B.hs:3:5: error: Variable not in scope: z
== Dep_Error_MM_A
-can't find file: A.hs
+A.hs:3:1: error:
+ Could not find module ‘B’
+ Use -v (or `:set -v` in ghci) to see a list of the files searched for.
== Dep_DM_AB
-can't find file: B.hs
-
== Dep_Error_DM_AB
-can't find file: B.hs
+B.hs:3:5: error: Variable not in scope: z
== Dep_Error_DM_A
A.hs:3:1: error:
Could not find module ‘B’
Use -v (or `:set -v` in ghci) to see a list of the files searched for.
== Dep_MD_AB
-can't find file: A.hs
-
== Dep_Error_MD_AB
-can't find file: A.hs
+B.hs:3:5: error: Variable not in scope: z
== Dep_Error_MD_A
-can't find file: A.hs
+B.hs:3:5: error: Variable not in scope: z