diff options
author | Michael Smith <michael@diglumi.com> | 2015-09-02 13:56:27 +0200 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-09-02 13:56:31 +0200 |
commit | ba5554ec2753cc41f5e087a91f23e1f612a9eb29 (patch) | |
tree | cd1c3c652e1b9be97c6b8b7ec639596a4ffaea47 /testsuite/tests/annotations/should_compile | |
parent | 296bc70b5ff6c853f2782e9ec5aa47a52110345e (diff) | |
download | haskell-ba5554ec2753cc41f5e087a91f23e1f612a9eb29.tar.gz |
Allow annotations though addTopDecls (#10486)
addTopDecls restricts what declarations it can be used to add. Adding
annotations via this method works fine with no special changes apart
from adding AnnD to the declaration whitelist.
Test Plan: validate
Reviewers: austin, goldfire, bgamari
Reviewed By: bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D1201
GHC Trac Issues: #10486
Diffstat (limited to 'testsuite/tests/annotations/should_compile')
3 files changed, 18 insertions, 8 deletions
diff --git a/testsuite/tests/annotations/should_compile/th/TestModuleTH.hs b/testsuite/tests/annotations/should_compile/th/TestModuleTH.hs index f21b13764b..715cc255cf 100644 --- a/testsuite/tests/annotations/should_compile/th/TestModuleTH.hs +++ b/testsuite/tests/annotations/should_compile/th/TestModuleTH.hs @@ -3,16 +3,26 @@ module TestModuleTH where import Language.Haskell.TH +import Language.Haskell.TH.Syntax (addTopDecls) $(do modAnn <- pragAnnD ModuleAnnotation (stringE "TH module annotation") + modAnn' <- pragAnnD ModuleAnnotation + (stringE "addTopDecls module annotation") [typ] <- [d| data TestTypeTH = TestTypeTH |] conAnn <- pragAnnD (ValueAnnotation $ mkName "TestTypeTH") (stringE "TH Constructor annotation") + conAnn' <- pragAnnD (ValueAnnotation $ mkName "TestTypeTH") + (stringE "addTopDecls Constructor annotation") typAnn <- pragAnnD (TypeAnnotation $ mkName "TestTypeTH") (stringE "TH Type annotation") + typAnn' <- pragAnnD (TypeAnnotation $ mkName "TestTypeTH") + (stringE "addTopDecls Type annotation") valAnn <- pragAnnD (ValueAnnotation $ mkName "testValueTH") (stringE "TH Value annotation") + valAnn' <- pragAnnD (ValueAnnotation $ mkName "testValueTH") + (stringE "addTopDecls value annotation") [val] <- [d| testValueTH = (42 :: Int) |] + addTopDecls [modAnn', conAnn', typAnn', valAnn'] return [modAnn, conAnn, typAnn, typ, valAnn, val] ) diff --git a/testsuite/tests/annotations/should_compile/th/annth_compunits.stdout b/testsuite/tests/annotations/should_compile/th/annth_compunits.stdout index 96e4642c7e..51fa405556 100644 --- a/testsuite/tests/annotations/should_compile/th/annth_compunits.stdout +++ b/testsuite/tests/annotations/should_compile/th/annth_compunits.stdout @@ -1,7 +1,7 @@ -["TH module annotation","Module annotation"] +["TH module annotation","addTopDecls module annotation","Module annotation"] ["Value annotation"] -["TH Value annotation"] +["TH Value annotation","addTopDecls value annotation"] ["Type annotation"] -["TH Type annotation"] +["TH Type annotation","addTopDecls Type annotation"] ["Constructor annotation"] -["TH Constructor annotation"] +["TH Constructor annotation","addTopDecls Constructor annotation"] diff --git a/testsuite/tests/annotations/should_compile/th/annth_make.stdout b/testsuite/tests/annotations/should_compile/th/annth_make.stdout index 96e4642c7e..51fa405556 100644 --- a/testsuite/tests/annotations/should_compile/th/annth_make.stdout +++ b/testsuite/tests/annotations/should_compile/th/annth_make.stdout @@ -1,7 +1,7 @@ -["TH module annotation","Module annotation"] +["TH module annotation","addTopDecls module annotation","Module annotation"] ["Value annotation"] -["TH Value annotation"] +["TH Value annotation","addTopDecls value annotation"] ["Type annotation"] -["TH Type annotation"] +["TH Type annotation","addTopDecls Type annotation"] ["Constructor annotation"] -["TH Constructor annotation"] +["TH Constructor annotation","addTopDecls Constructor annotation"] |