summaryrefslogtreecommitdiff
path: root/compiler/GHC/Parser/PostProcess.hs
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2020-09-30 23:14:25 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-10-09 08:47:36 -0400
commit36787bba78ae5acbb857c84b85b8feb7c83e54a5 (patch)
treeb7b2ad12a62e4218f9e347c9b12929043d93a1aa /compiler/GHC/Parser/PostProcess.hs
parent12191a99d3b978b697ec0fb4412276fbea5dce8f (diff)
downloadhaskell-36787bba78ae5acbb857c84b85b8feb7c83e54a5.tar.gz
ApiAnnotations : preserve parens in GADTs
A cleanup in 7f418acf61e accidentally discarded some parens in ConDeclGADT. Make sure these stay in the AST in a usable format. Also ensure the AnnLolly does not get lost in a GADT.
Diffstat (limited to 'compiler/GHC/Parser/PostProcess.hs')
-rw-r--r--compiler/GHC/Parser/PostProcess.hs13
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/GHC/Parser/PostProcess.hs b/compiler/GHC/Parser/PostProcess.hs
index 2fd38dbdba..4294046d1f 100644
--- a/compiler/GHC/Parser/PostProcess.hs
+++ b/compiler/GHC/Parser/PostProcess.hs
@@ -633,16 +633,16 @@ mkConDeclH98 name mb_forall mb_cxt args
-- Note [GADT abstract syntax] in "GHC.Hs.Decls" for more details.
mkGadtDecl :: [Located RdrName]
-> LHsType GhcPs
- -> P (ConDecl GhcPs)
+ -> P (ConDecl GhcPs, [AddAnn])
mkGadtDecl names ty = do
- let (args, res_ty)
+ let (args, res_ty, anns)
| L _ (HsFunTy _ _w (L loc (HsRecTy _ rf)) res_ty) <- body_ty
- = (RecCon (L loc rf), res_ty)
+ = (RecCon (L loc rf), res_ty, [])
| otherwise
- = let (arg_types, res_type) = splitHsFunType body_ty
- in (PrefixCon arg_types, res_type)
+ = let (arg_types, res_type, anns) = splitHsFunType body_ty
+ in (PrefixCon arg_types, res_type, anns)
- pure $ ConDeclGADT { con_g_ext = noExtField
+ pure ( ConDeclGADT { con_g_ext = noExtField
, con_names = names
, con_forall = L (getLoc ty) $ isJust mtvs
, con_qvars = fromMaybe [] mtvs
@@ -650,6 +650,7 @@ mkGadtDecl names ty = do
, con_args = args
, con_res_ty = res_ty
, con_doc = Nothing }
+ , anns )
where
(mtvs, mcxt, body_ty) = splitLHsGadtTy ty