summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/hieFile/HieAst.hs12
-rw-r--r--compiler/hieFile/HieTypes.hs13
-rw-r--r--compiler/main/HscMain.hs5
3 files changed, 25 insertions, 5 deletions
diff --git a/compiler/hieFile/HieAst.hs b/compiler/hieFile/HieAst.hs
index 0040b30cde..7fd217cda5 100644
--- a/compiler/hieFile/HieAst.hs
+++ b/compiler/hieFile/HieAst.hs
@@ -34,6 +34,8 @@ import TcHsSyn ( hsLitType, hsPatType )
import Type ( mkFunTys, Type )
import TysWiredIn ( mkListTy, mkSumTy )
import Var ( Id, Var, setVarName, varName, varType )
+import TcRnTypes
+import MkIface ( mkIfaceExports )
import HieTypes
import HieUtils
@@ -87,17 +89,23 @@ modifyState = foldr go id
type HieM = ReaderT HieState Hsc
-- | Construct an 'HieFile' from the outputs of the typechecker.
-mkHieFile :: ModSummary -> TypecheckedSource -> RenamedSource -> Hsc HieFile
+mkHieFile :: ModSummary
+ -> TcGblEnv
+ -> RenamedSource -> Hsc HieFile
mkHieFile ms ts rs = do
- (asts', arr) <- getCompressedAsts ts rs
+ let tc_binds = tcg_binds ts
+ (asts', arr) <- getCompressedAsts tc_binds rs
let Just src_file = ml_hs_file $ ms_location ms
src <- liftIO $ BS.readFile src_file
return $ HieFile
{ hie_version = curHieVersion
, hie_ghc_version = BSC.pack cProjectVersion
, hie_hs_file = src_file
+ , hie_module = ms_mod ms
, hie_types = arr
, hie_asts = asts'
+ -- mkIfaceExports sorts the AvailInfos for stability
+ , hie_exports = mkIfaceExports (tcg_exports ts)
, hie_hs_src = src
}
diff --git a/compiler/hieFile/HieTypes.hs b/compiler/hieFile/HieTypes.hs
index c20887f045..1b1d8c5275 100644
--- a/compiler/hieFile/HieTypes.hs
+++ b/compiler/hieFile/HieTypes.hs
@@ -10,10 +10,11 @@ import GhcPrelude
import Binary
import FastString ( FastString )
import IfaceType
-import Module ( ModuleName )
+import Module ( ModuleName, Module )
import Name ( Name )
import Outputable hiding ( (<>) )
import SrcLoc ( RealSrcSpan )
+import Avail
import qualified Data.Array as A
import qualified Data.Map as M
@@ -56,6 +57,9 @@ data HieFile = HieFile
, hie_hs_file :: FilePath
-- ^ Initial Haskell source file path
+ , hie_module :: Module
+ -- ^ The module this HIE file is for
+
, hie_types :: A.Array TypeIndex HieTypeFlat
-- ^ Types referenced in the 'hie_asts'.
--
@@ -64,6 +68,9 @@ data HieFile = HieFile
, hie_asts :: HieASTs TypeIndex
-- ^ Type-annotated abstract syntax trees
+ , hie_exports :: [AvailInfo]
+ -- ^ The names that this module exports
+
, hie_hs_src :: ByteString
-- ^ Raw bytes of the initial Haskell source
}
@@ -73,8 +80,10 @@ instance Binary HieFile where
put_ bh $ hie_version hf
put_ bh $ hie_ghc_version hf
put_ bh $ hie_hs_file hf
+ put_ bh $ hie_module hf
put_ bh $ hie_types hf
put_ bh $ hie_asts hf
+ put_ bh $ hie_exports hf
put_ bh $ hie_hs_src hf
get bh = HieFile
@@ -84,6 +93,8 @@ instance Binary HieFile where
<*> get bh
<*> get bh
<*> get bh
+ <*> get bh
+ <*> get bh
{-
diff --git a/compiler/main/HscMain.hs b/compiler/main/HscMain.hs
index 9a4dd4aafe..674afc9f47 100644
--- a/compiler/main/HscMain.hs
+++ b/compiler/main/HscMain.hs
@@ -408,8 +408,9 @@ extract_renamed_stuff mod_summary tc_result = do
-- Create HIE files
when (gopt Opt_WriteHie dflags) $ do
- hieFile <- mkHieFile mod_summary (tcg_binds tc_result)
- (fromJust rn_info)
+ -- I assume this fromJust is safe because `-fwrite-hie-file`
+ -- enables the option which keeps the renamed source.
+ hieFile <- mkHieFile mod_summary tc_result (fromJust rn_info)
let out_file = ml_hie_file $ ms_location mod_summary
liftIO $ writeHieFile out_file hieFile