ApiAnnotations : mkGadtDecl discards annotations for HsFunTy
authorAlan Zimmerman <alan.zimm@gmail.com>
Mon, 11 May 2015 08:57:25 +0000 (10:57 +0200)
committerAlan Zimmerman <alan.zimm@gmail.com>
Mon, 11 May 2015 08:57:25 +0000 (10:57 +0200)
commite4032b1951a35d8df63a74ebfee7449988b5ef40
treec1e51275ba5a23411de3ea6248e620262bbfc2af
parent811b72adedcd12149783eac19ebccff1dd72bc1c
ApiAnnotations : mkGadtDecl discards annotations for HsFunTy

Summary:
When mkGadtDecl is presented wih a HsFunTy it discards the SrcSpan, thus
disconnecting any annotations on the HsFunTy.

```
mkGadtDecl names (L ls (HsForAllTy imp Nothing qvars cxt tau))
  = return $ mk_gadt_con names
  where
    (details, res_ty)           -- See Note [Sorting out the result type]
      = case tau of
          L _ (HsFunTy (L l (HsRecTy flds)) res_ty)
                                            -> (RecCon (L l flds), res_ty)
          _other                                    -> (PrefixCon [], tau)
...
```

This can be triggered by the following

```
{-# LANGUAGE GADTs #-}
module GADTRecords2 (H1(..)) where

-- | h1
data H1 a b where
  C3 :: (Num a) => { field :: a -- ^ hello docs
                   } -> H1 Int Int
```

Test Plan: ./validate

Reviewers: hvr, austin

Reviewed By: austin

Subscribers: bgamari, thomie, mpickering

Differential Revision: https://phabricator.haskell.org/D848

GHC Trac Issues: #10309
compiler/parser/Parser.y
testsuite/tests/ghc-api/annotations/.gitignore
testsuite/tests/ghc-api/annotations/Makefile
testsuite/tests/ghc-api/annotations/T10255.stdout
testsuite/tests/ghc-api/annotations/T10309.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/T10312.stdout
testsuite/tests/ghc-api/annotations/Test10309.hs [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/all.T
testsuite/tests/ghc-api/annotations/t10309.hs [new file with mode: 0644]