@@ -29,8 +29,14 @@ import Development.IDE (FileDiagnostic,
29
29
import Development.IDE.Core.PluginUtils
30
30
import Development.IDE.Core.RuleTypes (GetParsedModule (GetParsedModule ))
31
31
import 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 )
34
40
import Development.IDE.GHC.Util (printOutputable )
35
41
import Development.IDE.Types.Diagnostics (_SomeStructuredMessage )
36
42
import Generics.SYB (extQ , something )
@@ -138,8 +144,8 @@ diagnosticToChangeSig recorder decls diagnostic = runMaybeT $ do
138
144
(expectedType, actualType, errInfo) <- hoistMaybe $ do
139
145
msg <- diagnostic ^. fdStructuredMessageL ^? _SomeStructuredMessage
140
146
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
143
149
mismatch <- solverReport ^? _MismatchMessage
144
150
expectedType <- mismatch ^? _TypeEqMismatchExpected
145
151
actualType <- mismatch ^? _TypeEqMismatchActual
@@ -164,49 +170,6 @@ diagnosticToChangeSig recorder decls diagnostic = runMaybeT $ do
164
170
showType :: Type -> Text
165
171
showType = T. pack . showSDocUnsafe . pprTidiedType
166
172
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
-
210
173
-- | If a diagnostic has the proper message create a ChangeSignature from it
211
174
matchingDiagnostic :: ErrInfo -> Maybe DeclName
212
175
matchingDiagnostic ErrInfo {errInfoContext} =
0 commit comments