@@ -29,8 +29,14 @@ import Development.IDE (FileDiagnostic,
2929import Development.IDE.Core.PluginUtils
3030import Development.IDE.Core.RuleTypes (GetParsedModule (GetParsedModule ))
3131import Development.IDE.GHC.Compat hiding (vcat )
32- import Development.IDE.GHC.Compat.Error (_TcRnMessageWithCtx ,
33- msgEnvelopeErrorL )
32+ import Development.IDE.GHC.Compat.Error (_MismatchMessage ,
33+ _TcRnMessageWithCtx ,
34+ _TcRnMessageWithInfo ,
35+ _TcRnSolverReport ,
36+ _TypeEqMismatchActual ,
37+ _TypeEqMismatchExpected ,
38+ msgEnvelopeErrorL ,
39+ reportContentL )
3440import Development.IDE.GHC.Util (printOutputable )
3541import Development.IDE.Types.Diagnostics (_SomeStructuredMessage )
3642import Generics.SYB (extQ , something )
@@ -138,8 +144,8 @@ diagnosticToChangeSig recorder decls diagnostic = runMaybeT $ do
138144 (expectedType, actualType, errInfo) <- hoistMaybe $ do
139145 msg <- diagnostic ^. fdStructuredMessageL ^? _SomeStructuredMessage
140146 tcRnMsg <- msg ^. msgEnvelopeErrorL ^? _TcRnMessageWithCtx
141- TcRnMessageDetailed errInfo tcRnMsg' <- tcRnMsg ^? _TcRnMessageDetailed
142- solverReport <- tcRnMsg' ^? _TcRnSolverReport . tcSolverReportMsgL
147+ (_, TcRnMessageDetailed errInfo tcRnMsg') <- tcRnMsg ^? _TcRnMessageWithInfo
148+ solverReport <- tcRnMsg' ^? _TcRnSolverReport . _1 . reportContentL
143149 mismatch <- solverReport ^? _MismatchMessage
144150 expectedType <- mismatch ^? _TypeEqMismatchExpected
145151 actualType <- mismatch ^? _TypeEqMismatchActual
@@ -164,49 +170,6 @@ diagnosticToChangeSig recorder decls diagnostic = runMaybeT $ do
164170 showType :: Type -> Text
165171 showType = T. pack . showSDocUnsafe . pprTidiedType
166172
167- _TcRnMessageDetailed :: Traversal' TcRnMessage TcRnMessageDetailed
168- _TcRnMessageDetailed focus (TcRnMessageWithInfo errInfo detailed) =
169- (\ detailed' -> TcRnMessageWithInfo errInfo detailed') <$> focus detailed
170- _TcRnMessageDetailed _ msg = pure msg
171-
172- _TcRnSolverReport :: Traversal' TcRnMessage SolverReportWithCtxt
173- #if MIN_VERSION_ghc(9,10,0)
174- _TcRnSolverReport focus (TcRnSolverReport report reason) =
175- (\ report' -> TcRnSolverReport report' reason) <$> focus report
176- #else
177- _TcRnSolverReport focus (TcRnSolverReport report reason hints) =
178- (\ report' -> TcRnSolverReport report' reason hints) <$> focus report
179- #endif
180- _TcRnSolverReport _ msg = pure msg
181-
182- tcSolverReportMsgL :: Lens' SolverReportWithCtxt TcSolverReportMsg
183- tcSolverReportMsgL = lens reportContent (\ report content' -> report { reportContent = content' })
184-
185- _MismatchMessage :: Traversal' TcSolverReportMsg MismatchMsg
186- _MismatchMessage focus (Mismatch msg t a c) = (\ msg' -> Mismatch msg' t a c) <$> focus msg
187- _MismatchMessage focus (CannotUnifyVariable msg a) = flip CannotUnifyVariable a <$> focus msg
188- _MismatchMessage _ report = pure report
189-
190- _TypeEqMismatchExpected :: Traversal' MismatchMsg Type
191- #if MIN_VERSION_ghc(9,12,0)
192- _TypeEqMismatchExpected focus mismatch@ (TypeEqMismatch _ _ _ expected _ _ _) =
193- (\ expected' -> mismatch { teq_mismatch_expected = expected' }) <$> focus expected
194- #else
195- _TypeEqMismatchExpected focus mismatch@ (TypeEqMismatch _ _ _ _ expected _ _ _) =
196- (\ expected' -> mismatch { teq_mismatch_expected = expected' }) <$> focus expected
197- #endif
198- _TypeEqMismatchExpected _ mismatch = pure mismatch
199-
200- _TypeEqMismatchActual :: Traversal' MismatchMsg Type
201- #if MIN_VERSION_ghc(9,12,0)
202- _TypeEqMismatchActual focus mismatch@ (TypeEqMismatch _ _ _ _ actual _ _) =
203- (\ actual' -> mismatch { teq_mismatch_actual = actual' }) <$> focus actual
204- #else
205- _TypeEqMismatchActual focus mismatch@ (TypeEqMismatch _ _ _ _ _ actual _ _) =
206- (\ actual' -> mismatch { teq_mismatch_expected = actual' }) <$> focus actual
207- #endif
208- _TypeEqMismatchActual _ mismatch = pure mismatch
209-
210173-- | If a diagnostic has the proper message create a ChangeSignature from it
211174matchingDiagnostic :: ErrInfo -> Maybe DeclName
212175matchingDiagnostic ErrInfo {errInfoContext} =
0 commit comments