summaryrefslogtreecommitdiff
path: root/compiler/hsSyn
diff options
context:
space:
mode:
authorAlan Zimmerman <alan.zimm@gmail.com>2018-06-18 10:18:21 +0200
committerAlan Zimmerman <alan.zimm@gmail.com>2018-06-19 13:19:20 +0200
commit676c5754e3f9e1beeb5f01e0265ffbdc0e6f49e9 (patch)
treeb4a69137a0688a7e339ac5763e5e7ca6f538d190 /compiler/hsSyn
parent83a7b1cf5f24eccc54016034d8a6d31dbbc2c263 (diff)
downloadhaskell-676c5754e3f9e1beeb5f01e0265ffbdc0e6f49e9.tar.gz
Fix API Annotations for GADT constructors
Summary: This patch completes the work for #14529 by making sure that all API Annotations end up attached to a SrcSpan that appears in the final ParsedSource. Updates Haddock submodule Test Plan: ./validate Reviewers: goldfire, bgamari Subscribers: rwbarton, thomie, mpickering, carter GHC Trac Issues: #14529 Differential Revision: https://phabricator.haskell.org/D4867
Diffstat (limited to 'compiler/hsSyn')
-rw-r--r--compiler/hsSyn/Convert.hs8
-rw-r--r--compiler/hsSyn/HsDecls.hs7
2 files changed, 9 insertions, 6 deletions
diff --git a/compiler/hsSyn/Convert.hs b/compiler/hsSyn/Convert.hs
index 7b721ed1f2..3da163c71d 100644
--- a/compiler/hsSyn/Convert.hs
+++ b/compiler/hsSyn/Convert.hs
@@ -535,14 +535,14 @@ cvtConstr (ForallC tvs ctxt con)
add_cxt (L loc cxt1) (Just (L _ cxt2)) = Just (L loc (cxt1 ++ cxt2))
add_forall tvs' cxt' con@(ConDeclGADT { con_qvars = qvars, con_mb_cxt = cxt })
- = con { con_forall = not (null all_tvs)
+ = con { con_forall = noLoc $ not (null all_tvs)
, con_qvars = mkHsQTvs all_tvs
, con_mb_cxt = add_cxt cxt' cxt }
where
all_tvs = hsQTvExplicit tvs' ++ hsQTvExplicit qvars
add_forall tvs' cxt' con@(ConDeclH98 { con_ex_tvs = ex_tvs, con_mb_cxt = cxt })
- = con { con_forall = not (null all_tvs)
+ = con { con_forall = noLoc $ not (null all_tvs)
, con_ex_tvs = all_tvs
, con_mb_cxt = add_cxt cxt' cxt }
where
@@ -555,7 +555,7 @@ cvtConstr (GadtC c strtys ty)
; args <- mapM cvt_arg strtys
; L _ ty' <- cvtType ty
; c_ty <- mk_arr_apps args ty'
- ; returnL $ mkGadtDecl c' c_ty}
+ ; returnL $ fst $ mkGadtDecl c' c_ty}
cvtConstr (RecGadtC c varstrtys ty)
= do { c' <- mapM cNameL c
@@ -563,7 +563,7 @@ cvtConstr (RecGadtC c varstrtys ty)
; rec_flds <- mapM cvt_id_arg varstrtys
; let rec_ty = noLoc (HsFunTy noExt
(noLoc $ HsRecTy noExt rec_flds) ty')
- ; returnL $ mkGadtDecl c' rec_ty }
+ ; returnL $ fst $ mkGadtDecl c' rec_ty }
cvtSrcUnpackedness :: TH.SourceUnpackedness -> SrcUnpackedness
cvtSrcUnpackedness NoSourceUnpackedness = NoSrcUnpack
diff --git a/compiler/hsSyn/HsDecls.hs b/compiler/hsSyn/HsDecls.hs
index c7a0ea0716..7ac43543bb 100644
--- a/compiler/hsSyn/HsDecls.hs
+++ b/compiler/hsSyn/HsDecls.hs
@@ -1236,7 +1236,9 @@ data ConDecl pass
-- The next four fields describe the type after the '::'
-- See Note [GADT abstract syntax]
- , con_forall :: Bool -- ^ True <=> explicit forall
+ -- The following field is Located to anchor API Annotations,
+ -- AnnForall and AnnDot.
+ , con_forall :: Located Bool -- ^ True <=> explicit forall
-- False => hsq_explicit is empty
, con_qvars :: LHsQTyVars pass
-- Whether or not there is an /explicit/ forall, we still
@@ -1254,7 +1256,8 @@ data ConDecl pass
{ con_ext :: XConDeclH98 pass
, con_name :: Located (IdP pass)
- , con_forall :: Bool -- ^ True <=> explicit user-written forall
+ , con_forall :: Located Bool
+ -- ^ True <=> explicit user-written forall
-- e.g. data T a = forall b. MkT b (b->a)
-- con_ex_tvs = {b}
-- False => con_ex_tvs is empty