@@ -73,7 +73,7 @@ import Data.Time (UTCTime (..))
73
73
import Data.Tuple.Extra (dupe )
74
74
import Data.Unique as Unique
75
75
import Debug.Trace
76
- import Development.IDE.Core.FileStore (resetInterfaceStore , shareFilePath )
76
+ import Development.IDE.Core.FileStore (resetInterfaceStore )
77
77
import Development.IDE.Core.Preprocessor
78
78
import Development.IDE.Core.RuleTypes
79
79
import Development.IDE.Core.Shake
@@ -147,6 +147,13 @@ import GHC.Driver.Config.CoreToStg.Prep
147
147
import GHC.Core.Lint.Interactive
148
148
#endif
149
149
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
+
150
157
-- Simple constants to make sure the source is consistently named
151
158
sourceTypecheck :: T. Text
152
159
sourceTypecheck = " typecheck"
@@ -479,11 +486,16 @@ filterUsages = id
479
486
-- Important to do this immediately after reading the unit before
480
487
-- anything else has a chance to read `mi_usages`
481
488
shareUsages :: 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}
483
494
where usages = map go (mi_usages iface)
484
495
go usg@ UsageFile {} = usg {usg_file_path = fp}
485
496
where ! fp = shareFilePath (usg_file_path usg)
486
497
go usg = usg
498
+ #endif
487
499
488
500
489
501
mkHiFileResultNoCompile :: HscEnv -> TcModuleResult -> IO HiFileResult
@@ -646,11 +658,24 @@ compileModule (RunSimplifier simplify) session ms tcg =
646
658
fmap (either (, Nothing ) (second Just )) $
647
659
catchSrcErrors (hsc_dflags session) " compile" $ do
648
660
(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
650
675
-- TODO: maybe settings ms_hspp_opts is unnecessary?
651
676
-- MP: the flags in ModSummary should be right, if they are wrong then
652
677
-- 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
654
679
if simplify
655
680
then do
656
681
plugins <- readIORef (tcg_th_coreplugins tcg)
@@ -779,23 +804,41 @@ unnecessaryDeprecationWarningFlags
779
804
, Opt_WarnUnusedForalls
780
805
, Opt_WarnUnusedRecordWildcards
781
806
, Opt_WarnInaccessibleCode
807
+ #if !MIN_VERSION_ghc(9,7,0)
782
808
, Opt_WarnWarningsDeprecations
809
+ #endif
783
810
]
784
811
785
812
-- | Add a unnecessary/deprecated tag to the required diagnostics.
786
813
#if MIN_VERSION_ghc(9,3,0)
787
814
tagDiag :: (Maybe DiagnosticReason , FileDiagnostic ) -> (Maybe DiagnosticReason , FileDiagnostic )
788
- tagDiag (w@ (Just (WarningWithFlag warning)), (nfp, sh, fd))
789
815
#else
790
816
tagDiag :: (WarnReason , FileDiagnostic ) -> (WarnReason , FileDiagnostic )
791
- tagDiag (w@ (Reason warning), (nfp, sh, fd))
792
817
#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))
793
832
| Just tag <- requiresTag warning
794
833
= (w, (nfp, sh, fd { _tags = Just $ tag : concat (_tags fd) }))
834
+ #endif
795
835
where
796
836
requiresTag :: WarningFlag -> Maybe DiagnosticTag
837
+ #if !MIN_VERSION_ghc(9,7,0)
838
+ -- doesn't exist on 9.8, we use WarningWithCategory instead
797
839
requiresTag Opt_WarnWarningsDeprecations
798
840
= Just DiagnosticTag_Deprecated
841
+ #endif
799
842
requiresTag wflag -- deprecation was already considered above
800
843
| wflag `elem` unnecessaryDeprecationWarningFlags
801
844
= Just DiagnosticTag_Unnecessary
0 commit comments