API Annotations when parsing typapp
authorAlan Zimmerman <alan.zimm@gmail.com>
Tue, 26 Jun 2018 09:07:07 +0000 (11:07 +0200)
committerAlan Zimmerman <alan.zimm@gmail.com>
Tue, 26 Jun 2018 09:09:50 +0000 (11:09 +0200)
Make sure the original annotations are still accessible for a promoted
type.

Closes #15303

compiler/parser/Parser.y
testsuite/tests/ghc-api/annotations/Makefile
testsuite/tests/ghc-api/annotations/T15303.stdout [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/Test15303.hs [new file with mode: 0644]
testsuite/tests/ghc-api/annotations/all.T

index 6b0317b..d038562 100644 (file)
@@ -1930,9 +1930,9 @@ tyapp :: { Located TyEl }
         | qtyconop                      { sL1 $1 $ TyElOpr (unLoc $1) }
         | tyvarop                       { sL1 $1 $ TyElOpr (unLoc $1) }
         | SIMPLEQUOTE qconop            {% ams (sLL $1 $> $ TyElOpr (unLoc $2))
-                                               [mj AnnSimpleQuote $1] }
+                                               [mj AnnSimpleQuote $1,mj AnnVal $2] }
         | SIMPLEQUOTE varop             {% ams (sLL $1 $> $ TyElOpr (unLoc $2))
-                                               [mj AnnSimpleQuote $1] }
+                                               [mj AnnSimpleQuote $1,mj AnnVal $2] }
 
 atype_docs :: { LHsType GhcPs }
         : atype docprev                 { sLL $1 $> $ HsDocTy noExt $1 $2 }
index 2da5fc0..98b4574 100644 (file)
@@ -141,3 +141,7 @@ T12417:
 .PHONY: T13163
 T13163:
        $(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test13163.hs
+
+.PHONY: T15303
+T15303:
+       $(CHECK_API_ANNOTATIONS) "`'$(TEST_HC)' $(TEST_HC_OPTS) --print-libdir | tr -d '\r'`" Test15303.hs
diff --git a/testsuite/tests/ghc-api/annotations/T15303.stdout b/testsuite/tests/ghc-api/annotations/T15303.stdout
new file mode 100644 (file)
index 0000000..003dab5
--- /dev/null
@@ -0,0 +1,35 @@
+---Problems (should be empty list)---
+[]
+---Annotations-----------------------
+-- SrcSpan the annotation is attached to, AnnKeywordId,
+--    list of locations the keyword item appears in
+[
+((Test15303.hs:4:1-4,AnnCloseP), [Test15303.hs:4:4]),
+((Test15303.hs:4:1-4,AnnOpenP), [Test15303.hs:4:1]),
+((Test15303.hs:4:1-4,AnnVal), [Test15303.hs:4:2-3]),
+((Test15303.hs:4:1-66,AnnDcolon), [Test15303.hs:4:6-7]),
+((Test15303.hs:4:1-66,AnnSemi), [Test15303.hs:5:1]),
+((Test15303.hs:4:9-17,AnnDarrow), [Test15303.hs:4:19-20]),
+((Test15303.hs:4:22-41,AnnRarrow), [Test15303.hs:4:43-44]),
+((Test15303.hs:4:22-66,AnnRarrow), [Test15303.hs:4:43-44]),
+((Test15303.hs:4:33-41,AnnCloseP), [Test15303.hs:4:41]),
+((Test15303.hs:4:33-41,AnnOpenP), [Test15303.hs:4:33]),
+((Test15303.hs:4:36-37,AnnSimpleQuote), [Test15303.hs:4:36]),
+((Test15303.hs:4:36-37,AnnVal), [Test15303.hs:4:37]),
+((Test15303.hs:4:46-48,AnnRarrow), [Test15303.hs:4:50-51]),
+((Test15303.hs:4:46-66,AnnRarrow), [Test15303.hs:4:50-51]),
+((Test15303.hs:4:58-66,AnnCloseP), [Test15303.hs:4:66]),
+((Test15303.hs:4:58-66,AnnOpenP), [Test15303.hs:4:58]),
+((Test15303.hs:4:61-62,AnnSimpleQuote), [Test15303.hs:4:61]),
+((Test15303.hs:4:61-62,AnnVal), [Test15303.hs:4:62]),
+((Test15303.hs:5:1-4,AnnCloseP), [Test15303.hs:5:4]),
+((Test15303.hs:5:1-4,AnnOpenP), [Test15303.hs:5:1]),
+((Test15303.hs:5:1-4,AnnVal), [Test15303.hs:5:2-3]),
+((Test15303.hs:5:1-15,AnnEqual), [Test15303.hs:5:6]),
+((Test15303.hs:5:1-15,AnnFunId), [Test15303.hs:5:1-4]),
+((Test15303.hs:5:1-15,AnnSemi), [Test15303.hs:6:1]),
+((Test15303.hs:6:1-11,AnnInfix), [Test15303.hs:6:1-6]),
+((Test15303.hs:6:1-11,AnnSemi), [Test15303.hs:7:1]),
+((Test15303.hs:6:1-11,AnnVal), [Test15303.hs:6:8]),
+((<no location info>,AnnEofPos), [Test15303.hs:7:1])
+]
diff --git a/testsuite/tests/ghc-api/annotations/Test15303.hs b/testsuite/tests/ghc-api/annotations/Test15303.hs
new file mode 100644 (file)
index 0000000..212e9da
--- /dev/null
@@ -0,0 +1,6 @@
+{-# LANGUAGE DataKinds              #-}
+{-# LANGUAGE TypeOperators          #-}
+
+(~#) :: Comonad w => CascadeW w (t ': ts) -> w t -> Last (t ': ts)
+(~#) = cascadeW
+infixr 0 ~#
index adc0d14..666cb3f 100644 (file)
@@ -57,3 +57,5 @@ test('T12417',      [extra_files(['Test12417.hs']),
                      ignore_stderr], run_command, ['$MAKE -s --no-print-directory T12417'])
 test('T13163',      [extra_files(['Test13163.hs']),
                      ignore_stderr], run_command, ['$MAKE -s --no-print-directory T13163'])
+test('T15303',      [extra_files(['Test15303.hs']),
+                     ignore_stderr], run_command, ['$MAKE -s --no-print-directory T15303'])