@@ -295,24 +295,56 @@ data SpliceClass where
295
295
OneToOneAST :: HasSplice AnnListItem ast => Proxy # ast -> SpliceClass
296
296
IsHsDecl :: SpliceClass
297
297
298
+ #if MIN_VERSION_ghc(9,5,0)
299
+ data HsSpliceCompat pass
300
+ = UntypedSplice (HsUntypedSplice pass )
301
+ | TypedSplice (LHsExpr pass )
302
+ #endif
303
+
304
+
298
305
class (Outputable (ast GhcRn ), ASTElement l (ast GhcPs )) => HasSplice l ast where
299
306
type SpliceOf ast :: Kinds. Type -> Kinds. Type
300
- type SpliceOf ast = HsSplice
301
307
matchSplice :: Proxy # ast -> ast GhcPs -> Maybe (SpliceOf ast GhcPs )
302
308
expandSplice :: Proxy # ast -> SpliceOf ast GhcPs -> RnM (Either (ast GhcPs ) (ast GhcRn ), FreeVars )
303
309
304
310
instance HasSplice AnnListItem HsExpr where
311
+ #if MIN_VERSION_ghc(9,5,0)
312
+ type SpliceOf HsExpr = HsSpliceCompat
313
+ matchSplice _ (HsUntypedSplice _ spl) = Just (UntypedSplice spl)
314
+ matchSplice _ (HsTypedSplice _ spl) = Just (TypedSplice spl)
315
+ #else
316
+ type SpliceOf HsExpr = HsSplice
305
317
matchSplice _ (HsSpliceE _ spl) = Just spl
318
+ #endif
306
319
matchSplice _ _ = Nothing
320
+ #if MIN_VERSION_ghc(9,5,0)
321
+ expandSplice _ (UntypedSplice e) = fmap (first Right ) $ rnUntypedSpliceExpr e
322
+ expandSplice _ (TypedSplice e) = fmap (first Right ) $ rnTypedSplice e
323
+ #else
307
324
expandSplice _ = fmap (first Right ) . rnSpliceExpr
325
+ #endif
308
326
309
327
instance HasSplice AnnListItem Pat where
328
+ #if MIN_VERSION_ghc(9,5,0)
329
+ type SpliceOf Pat = HsUntypedSplice
330
+ #else
331
+ type SpliceOf Pat = HsSplice
332
+ #endif
310
333
matchSplice _ (SplicePat _ spl) = Just spl
311
334
matchSplice _ _ = Nothing
312
- expandSplice _ = rnSplicePat
335
+ expandSplice _ =
336
+ #if MIN_VERSION_ghc(9,5,0)
337
+ fmap (first (Left . unLoc . utsplice_result . snd )) .
338
+ #endif
339
+ rnSplicePat
313
340
314
341
315
342
instance HasSplice AnnListItem HsType where
343
+ #if MIN_VERSION_ghc(9,5,0)
344
+ type SpliceOf HsType = HsUntypedSplice
345
+ #else
346
+ type SpliceOf HsType = HsSplice
347
+ #endif
316
348
matchSplice _ (HsSpliceTy _ spl) = Just spl
317
349
matchSplice _ _ = Nothing
318
350
expandSplice _ = fmap (first Right ) . rnSpliceType
@@ -401,10 +433,15 @@ manualCalcEdit clientCapabilities reportEditor ran ps hscEnv typechkd srcSpan _e
401
433
showBag :: Error. Diagnostic a => Bag (Error. MsgEnvelope a ) -> String
402
434
showBag = show . fmap (fmap toDiagnosticMessage)
403
435
404
- toDiagnosticMessage :: Error. Diagnostic a => a -> Error. DiagnosticMessage
436
+ toDiagnosticMessage :: forall a . Error. Diagnostic a => a -> Error. DiagnosticMessage
405
437
toDiagnosticMessage message =
406
438
Error. DiagnosticMessage
407
- { diagMessage = Error. diagnosticMessage message
439
+ { diagMessage = Error. diagnosticMessage
440
+ #if MIN_VERSION_ghc(9,5,0)
441
+ (Error. defaultDiagnosticOpts @ a )
442
+ #endif
443
+ message
444
+
408
445
, diagReason = Error. diagnosticReason message
409
446
, diagHints = Error. diagnosticHints message
410
447
}
@@ -480,7 +517,12 @@ codeAction state plId (CodeActionParams _ _ docId ran _) = liftIO $
480
517
(L (AsSrcSpan l@ (RealSrcSpan spLoc _)) expr :: LHsExpr GhcPs )
481
518
| spanIsRelevant l ->
482
519
case expr of
520
+ #if MIN_VERSION_ghc(9,5,0)
521
+ HsTypedSplice {} -> Here (spLoc, Expr )
522
+ HsUntypedSplice {} -> Here (spLoc, Expr )
523
+ #else
483
524
HsSpliceE {} -> Here (spLoc, Expr )
525
+ #endif
484
526
_ -> Continue
485
527
_ -> Stop
486
528
)
0 commit comments