@@ -81,7 +81,15 @@ import MkIface
81
81
import StringBuffer as SB
82
82
import TcIface (typecheckIface )
83
83
import TcRnMonad hiding (newUnique )
84
+ #if MIN_GHC_API_VERSION(9,0,1)
85
+ import GHC.Builtin.Names
86
+ import GHC.Iface.Recomp
87
+ import GHC.Tc.Gen.Splice
88
+ import GHC.Tc.Types.Evidence (EvBind )
89
+ #else
90
+ import PrelNames
84
91
import TcSplice
92
+ #endif
85
93
import TidyPgm
86
94
87
95
import Bag
@@ -104,7 +112,6 @@ import qualified GHC.LanguageExtensions as LangExt
104
112
import HeaderInfo
105
113
import Linker (unload )
106
114
import Maybes (orElse )
107
- import PrelNames
108
115
import System.Directory
109
116
import System.FilePath
110
117
import System.IO.Extra (fixIO , newTempFileWithin )
@@ -144,10 +151,10 @@ computePackageDeps
144
151
-> IO (Either [FileDiagnostic ] [InstalledUnitId ])
145
152
computePackageDeps env pkg = do
146
153
let dflags = hsc_dflags env
147
- case lookupInstalledPackage dflags pkg of
154
+ case oldLookupInstalledPackage dflags pkg of
148
155
Nothing -> return $ Left [ideErrorText (toNormalizedFilePath' noFilePath) $
149
156
T. pack $ " unknown package: " ++ show pkg]
150
- Just pkgInfo -> return $ Right $ depends pkgInfo
157
+ Just pkgInfo -> return $ Right $ unitDepends pkgInfo
151
158
152
159
typecheckModule :: IdeDefer
153
160
-> HscEnv
@@ -268,7 +275,10 @@ mkHiFileResultCompile session' tcm simplified_guts ltype = catchErrs $ do
268
275
(guts, details) <- tidyProgram session simplified_guts
269
276
(diags, linkable) <- genLinkable session ms guts
270
277
pure (linkable, details, diags)
271
- #if MIN_GHC_API_VERSION(8,10,0)
278
+ #if MIN_GHC_API_VERSION(9,0,1)
279
+ let ! partial_iface = force (mkPartialIface session details simplified_guts)
280
+ final_iface <- mkFullIface session partial_iface Nothing
281
+ #elif MIN_GHC_API_VERSION(8,10,0)
272
282
let ! partial_iface = force (mkPartialIface session details simplified_guts)
273
283
final_iface <- mkFullIface session partial_iface
274
284
#else
@@ -336,7 +346,11 @@ generateObjectCode session summary guts = do
336
346
target = defaultObjectTarget $ targetPlatform $ hsc_dflags session
337
347
#endif
338
348
session' = session { hsc_dflags = updOptLevel 0 $ (ms_hspp_opts summary') { outputFile = Just dot_o , hscTarget = target}}
349
+ #if MIN_GHC_API_VERSION(9,0,1)
350
+ (outputFilename, _mStub, _foreign_files, _cinfos) <- hscGenHardCode session' guts
351
+ #else
339
352
(outputFilename, _mStub, _foreign_files) <- hscGenHardCode session' guts
353
+ #endif
340
354
#if MIN_GHC_API_VERSION(8,10,0)
341
355
(ms_location summary')
342
356
#else
@@ -464,7 +478,15 @@ generateHieAsts hscEnv tcm =
464
478
-- don't export an interface which allows for additional information to be added to hie files.
465
479
let fake_splice_binds = listToBag (map (mkVarBind unitDataConId) (spliceExpresions $ tmrTopLevelSplices tcm))
466
480
real_binds = tcg_binds $ tmrTypechecked tcm
481
+ #if MIN_GHC_API_VERSION(9,0,1)
482
+ -- TODO: Use some proper values here!
483
+ evBinds = emptyBag @ EvBind :: Bag EvBind
484
+ clsInsts = [] :: [ClsInst ]
485
+ tyCons = [] :: [TyCon ]
486
+ Just <$> GHC. enrichHie (fake_splice_binds `unionBags` real_binds) (tmrRenamed tcm) evBinds clsInsts tyCons
487
+ #else
467
488
Just <$> GHC. enrichHie (fake_splice_binds `unionBags` real_binds) (tmrRenamed tcm)
489
+ #endif
468
490
where
469
491
dflags = hsc_dflags hscEnv
470
492
@@ -638,7 +660,7 @@ setupFinderCache mss session = do
638
660
639
661
-- Make modules available for others that import them,
640
662
-- by putting them in the finder cache.
641
- let ims = map (InstalledModule (thisInstalledUnitId $ hsc_dflags session) . moduleName . ms_mod) mss
663
+ let ims = map (installedModule (thisInstalledUnitId $ hsc_dflags session) . moduleName . ms_mod) mss
642
664
ifrs = zipWith (\ ms -> InstalledFound (ms_location ms)) mss ims
643
665
-- set the target and module graph in the session
644
666
graph = mkModuleGraph mss
@@ -696,7 +718,7 @@ getModSummaryFromImports env fp modTime contents = do
696
718
697
719
mod = fmap unLoc mb_mod `orElse` mAIN_NAME
698
720
699
- (src_idecls, ord_idecls) = partition (ideclSource. unLoc) imps
721
+ (src_idecls, ord_idecls) = partition (( == IsBoot ) . ideclSource. unLoc) imps
700
722
701
723
-- GHC.Prim doesn't exist physically, so don't go looking for it.
702
724
ordinary_imps = filter ((/= moduleName gHC_PRIM) . unLoc
@@ -765,7 +787,11 @@ parseHeader
765
787
=> DynFlags -- ^ flags to use
766
788
-> FilePath -- ^ the filename (for source locations)
767
789
-> SB. StringBuffer -- ^ Haskell module source text (full Unicode is supported)
790
+ #if MIN_GHC_API_VERSION(9,0,1)
791
+ -> ExceptT [FileDiagnostic ] m ([FileDiagnostic ], Located (HsModule ))
792
+ #else
768
793
-> ExceptT [FileDiagnostic ] m ([FileDiagnostic ], Located (HsModule GhcPs ))
794
+ #endif
769
795
parseHeader dflags filename contents = do
770
796
let loc = mkRealSrcLoc (mkFastString filename) 1 1
771
797
case unP Parser. parseHeader (mkPState dflags contents loc) of
@@ -814,10 +840,21 @@ parseFileContents env customPreprocessor filename ms = do
814
840
throwE $ diagFromErrMsg " parser" dflags $ mkPlainErrMsg dflags locErr msgErr
815
841
#endif
816
842
POk pst rdr_module ->
817
- let hpm_annotations =
843
+ let hpm_annotations :: ApiAnns
844
+ hpm_annotations =
845
+ #if MIN_GHC_API_VERSION(9,0,1)
846
+ -- Copied from GHC.Driver.Main
847
+ ApiAnns {
848
+ apiAnnItems = Map. fromListWith (++) $ annotations pst,
849
+ apiAnnEofPos = eof_pos pst,
850
+ apiAnnComments = Map. fromList (annotations_comments pst),
851
+ apiAnnRogueComments = comment_q pst
852
+ }
853
+ #else
818
854
(Map. fromListWith (++) $ annotations pst,
819
855
Map. fromList ((noSrcSpan,comment_q pst)
820
856
: annotations_comments pst))
857
+ #endif
821
858
(warns, errs) = getMessages pst dflags
822
859
in
823
860
do
@@ -840,7 +877,7 @@ parseFileContents env customPreprocessor filename ms = do
840
877
throwE $ diagFromStrings " parser" DsError errs
841
878
842
879
let preproc_warnings = diagFromStrings " parser" DsWarning preproc_warns
843
- parsed' <- liftIO $ applyPluginsParsedResultAction env dflags ms hpm_annotations parsed
880
+ parsed' <- liftIO $ applyPluginsParsedResultAction env dflags ms ( hpm_annotations) parsed
844
881
845
882
-- To get the list of extra source files, we take the list
846
883
-- that the parser gave us,
0 commit comments