@@ -73,7 +73,7 @@ import Data.Time (UTCTime (..))
7373import Data.Tuple.Extra (dupe )
7474import Data.Unique as Unique
7575import Debug.Trace
76- import Development.IDE.Core.FileStore (resetInterfaceStore , shareFilePath )
76+ import Development.IDE.Core.FileStore (resetInterfaceStore )
7777import Development.IDE.Core.Preprocessor
7878import Development.IDE.Core.RuleTypes
7979import Development.IDE.Core.Shake
@@ -147,6 +147,13 @@ import GHC.Driver.Config.CoreToStg.Prep
147147import GHC.Core.Lint.Interactive
148148#endif
149149
150+ #if MIN_VERSION_ghc(9,7,0)
151+ import Data.Foldable (toList )
152+ import GHC.Unit.Module.Warnings
153+ #else
154+ import Development.IDE.Core.FileStore (shareFilePath )
155+ #endif
156+
150157-- Simple constants to make sure the source is consistently named
151158sourceTypecheck :: T. Text
152159sourceTypecheck = " typecheck"
@@ -479,11 +486,16 @@ filterUsages = id
479486-- Important to do this immediately after reading the unit before
480487-- anything else has a chance to read `mi_usages`
481488shareUsages :: ModIface -> ModIface
482- shareUsages iface = iface {mi_usages = usages}
489+ shareUsages iface
490+ = iface
491+ -- Fixed upstream in GHC 9.8
492+ #if !MIN_VERSION_ghc(9,7,0)
493+ {mi_usages = usages}
483494 where usages = map go (mi_usages iface)
484495 go usg@ UsageFile {} = usg {usg_file_path = fp}
485496 where ! fp = shareFilePath (usg_file_path usg)
486497 go usg = usg
498+ #endif
487499
488500
489501mkHiFileResultNoCompile :: HscEnv -> TcModuleResult -> IO HiFileResult
@@ -646,11 +658,24 @@ compileModule (RunSimplifier simplify) session ms tcg =
646658 fmap (either (, Nothing ) (second Just )) $
647659 catchSrcErrors (hsc_dflags session) " compile" $ do
648660 (warnings,desugared_guts) <- withWarnings " compile" $ \ tweak -> do
649- let session' = tweak (hscSetFlags (ms_hspp_opts ms) session)
661+ -- Breakpoints don't survive roundtripping from disk
662+ -- and this trips up the verify-core-files check
663+ -- They may also lead to other problems.
664+ -- We have to setBackend ghciBackend in 9.8 as otherwise
665+ -- non-exported definitions are stripped out.
666+ -- However, setting this means breakpoints are generated.
667+ -- Solution: prevent breakpoing generation by unsetting
668+ -- Opt_InsertBreakpoints
669+ let session' = tweak $ flip hscSetFlags session
670+ #if MIN_VERSION_ghc(9,7,0)
671+ $ flip gopt_unset Opt_InsertBreakpoints
672+ $ setBackend ghciBackend
673+ #endif
674+ $ ms_hspp_opts ms
650675 -- TODO: maybe settings ms_hspp_opts is unnecessary?
651676 -- MP: the flags in ModSummary should be right, if they are wrong then
652677 -- the correct place to fix this is when the ModSummary is created.
653- desugar <- hscDesugar session' (ms { ms_hspp_opts = hsc_dflags session' }) tcg
678+ desugar <- hscDesugar session' (ms { ms_hspp_opts = hsc_dflags session' }) tcg
654679 if simplify
655680 then do
656681 plugins <- readIORef (tcg_th_coreplugins tcg)
@@ -779,23 +804,41 @@ unnecessaryDeprecationWarningFlags
779804 , Opt_WarnUnusedForalls
780805 , Opt_WarnUnusedRecordWildcards
781806 , Opt_WarnInaccessibleCode
807+ #if !MIN_VERSION_ghc(9,7,0)
782808 , Opt_WarnWarningsDeprecations
809+ #endif
783810 ]
784811
785812-- | Add a unnecessary/deprecated tag to the required diagnostics.
786813#if MIN_VERSION_ghc(9,3,0)
787814tagDiag :: (Maybe DiagnosticReason , FileDiagnostic ) -> (Maybe DiagnosticReason , FileDiagnostic )
788- tagDiag (w@ (Just (WarningWithFlag warning)), (nfp, sh, fd))
789815#else
790816tagDiag :: (WarnReason , FileDiagnostic ) -> (WarnReason , FileDiagnostic )
791- tagDiag (w@ (Reason warning), (nfp, sh, fd))
792817#endif
818+
819+ #if MIN_VERSION_ghc(9,7,0)
820+ tagDiag (w@ (Just (WarningWithCategory cat)), (nfp, sh, fd))
821+ | cat == defaultWarningCategory -- default warning category is for deprecations
822+ = (w, (nfp, sh, fd { _tags = Just $ DiagnosticTag_Deprecated : concat (_tags fd) }))
823+ tagDiag (w@ (Just (WarningWithFlags warnings)), (nfp, sh, fd))
824+ | tags <- mapMaybe requiresTag (toList warnings)
825+ = (w, (nfp, sh, fd { _tags = Just $ tags ++ concat (_tags fd) }))
826+ #elif MIN_VERSION_ghc(9,3,0)
827+ tagDiag (w@ (Just (WarningWithFlag warning)), (nfp, sh, fd))
828+ | Just tag <- requiresTag warning
829+ = (w, (nfp, sh, fd { _tags = Just $ tag : concat (_tags fd) }))
830+ #else
831+ tagDiag (w@ (Reason warning), (nfp, sh, fd))
793832 | Just tag <- requiresTag warning
794833 = (w, (nfp, sh, fd { _tags = Just $ tag : concat (_tags fd) }))
834+ #endif
795835 where
796836 requiresTag :: WarningFlag -> Maybe DiagnosticTag
837+ #if !MIN_VERSION_ghc(9,7,0)
838+ -- doesn't exist on 9.8, we use WarningWithCategory instead
797839 requiresTag Opt_WarnWarningsDeprecations
798840 = Just DiagnosticTag_Deprecated
841+ #endif
799842 requiresTag wflag -- deprecation was already considered above
800843 | wflag `elem` unnecessaryDeprecationWarningFlags
801844 = Just DiagnosticTag_Unnecessary
0 commit comments