@@ -29,17 +29,19 @@ 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 )
3743import GHC.Tc.Errors.Types (ErrInfo (.. ),
38- MismatchMsg (.. ),
39- SolverReportWithCtxt (.. ),
40- TcRnMessage (.. ),
41- TcRnMessageDetailed (.. ),
42- TcSolverReportMsg (.. ))
44+ TcRnMessageDetailed (.. ))
4345import qualified Ide.Logger as Logger
4446import Ide.Plugin.Error (PluginError ,
4547 getNormalizedFilePathE )
@@ -138,8 +140,8 @@ diagnosticToChangeSig recorder decls diagnostic = runMaybeT $ do
138140 (expectedType, actualType, errInfo) <- hoistMaybe $ do
139141 msg <- diagnostic ^. fdStructuredMessageL ^? _SomeStructuredMessage
140142 tcRnMsg <- msg ^. msgEnvelopeErrorL ^? _TcRnMessageWithCtx
141- TcRnMessageDetailed errInfo tcRnMsg' <- tcRnMsg ^? _TcRnMessageDetailed
142- solverReport <- tcRnMsg' ^? _TcRnSolverReport . tcSolverReportMsgL
143+ (_, TcRnMessageDetailed errInfo tcRnMsg') <- tcRnMsg ^? _TcRnMessageWithInfo
144+ solverReport <- tcRnMsg' ^? _TcRnSolverReport . _1 . reportContentL
143145 mismatch <- solverReport ^? _MismatchMessage
144146 expectedType <- mismatch ^? _TypeEqMismatchExpected
145147 actualType <- mismatch ^? _TypeEqMismatchActual
@@ -164,49 +166,6 @@ diagnosticToChangeSig recorder decls diagnostic = runMaybeT $ do
164166 showType :: Type -> Text
165167 showType = T. pack . showSDocUnsafe . pprTidiedType
166168
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-
210169-- | If a diagnostic has the proper message create a ChangeSignature from it
211170matchingDiagnostic :: ErrInfo -> Maybe DeclName
212171matchingDiagnostic ErrInfo {errInfoContext} =
0 commit comments