diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2016-11-03 14:40:12 +0200 |
---|---|---|
committer | Alan Zimmerman <alan.zimm@gmail.com> | 2016-11-03 20:45:05 +0200 |
commit | f46bfeb8344e1818f42066c3dd9717f49e8b511b (patch) | |
tree | 7f90fe96ae6a66dd364f5d06bc030c4360f00b80 | |
parent | ec22bacdd625b04d28228dd5522d59d0bc8b1152 (diff) | |
download | haskell-f46bfeb8344e1818f42066c3dd9717f49e8b511b.tar.gz |
API Annotations: make all ModuleName Located
Summary:
This also changes the backpack Renaming type to use a Maybe for the
renameTo field, to more accurately reflect the parsed source.
Updates haddock submodule to match AST changes
Test Plan: ./validate
Reviewers: ezyang, bgamari, austin
Reviewed By: bgamari
Subscribers: thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D2670
-rw-r--r-- | compiler/backpack/BkpSyn.hs | 3 | ||||
-rw-r--r-- | compiler/backpack/DriverBkp.hs | 9 | ||||
-rw-r--r-- | compiler/hsSyn/HsImpExp.hs | 2 | ||||
-rw-r--r-- | compiler/parser/Parser.y | 10 | ||||
-rw-r--r-- | compiler/rename/RnNames.hs | 2 | ||||
-rw-r--r-- | ghc/GHCi/UI.hs | 2 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/T10312.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/annotations.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/exampleTest.stdout | 1 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/listcomps.stdout | 16 | ||||
-rw-r--r-- | testsuite/tests/ghc-api/annotations/parseTree.stdout | 2 | ||||
m--------- | utils/haddock | 0 |
12 files changed, 23 insertions, 27 deletions
diff --git a/compiler/backpack/BkpSyn.hs b/compiler/backpack/BkpSyn.hs index ae03324b34..e019d03b24 100644 --- a/compiler/backpack/BkpSyn.hs +++ b/compiler/backpack/BkpSyn.hs @@ -73,5 +73,6 @@ data IncludeDecl n = IncludeDecl { -- | Rename a module from one name to another. The identity renaming -- means that the module should be brought into scope. -data Renaming = Renaming { renameFrom :: ModuleName, renameTo :: ModuleName } +data Renaming = Renaming { renameFrom :: Located ModuleName + , renameTo :: Maybe (Located ModuleName) } type LRenaming = Located Renaming diff --git a/compiler/backpack/DriverBkp.hs b/compiler/backpack/DriverBkp.hs index ccf74c8c9b..cdbe06d51f 100644 --- a/compiler/backpack/DriverBkp.hs +++ b/compiler/backpack/DriverBkp.hs @@ -213,9 +213,12 @@ hsunitDeps :: HsUnit HsComponentId -> [(UnitId, ModRenaming)] hsunitDeps unit = concatMap get_dep (hsunitBody unit) where get_dep (L _ (IncludeD (IncludeDecl (L _ hsuid) mb_lrn))) = [(convertHsUnitId hsuid, go mb_lrn)] - where go Nothing = ModRenaming True [] - go (Just lrns) = ModRenaming False (map convRn lrns) - where convRn (L _ (Renaming from to)) = (from, to) + where + go Nothing = ModRenaming True [] + go (Just lrns) = ModRenaming False (map convRn lrns) + where + convRn (L _ (Renaming (L _ from) Nothing)) = (from, from) + convRn (L _ (Renaming (L _ from) (Just (L _ to)))) = (from, to) get_dep _ = [] buildUnit :: SessionType -> ComponentId -> [(ModuleName, Module)] -> LHsUnit HsComponentId -> BkpM () diff --git a/compiler/hsSyn/HsImpExp.hs b/compiler/hsSyn/HsImpExp.hs index 6d709cceb4..011a80af22 100644 --- a/compiler/hsSyn/HsImpExp.hs +++ b/compiler/hsSyn/HsImpExp.hs @@ -53,7 +53,7 @@ data ImportDecl name ideclSafe :: Bool, -- ^ True => safe import ideclQualified :: Bool, -- ^ True => qualified ideclImplicit :: Bool, -- ^ True => implicit import (of Prelude) - ideclAs :: Maybe ModuleName, -- ^ as Module + ideclAs :: Maybe (Located ModuleName), -- ^ as Module ideclHiding :: Maybe (Bool, Located [LIE name]) -- ^ (True => hiding, names) } diff --git a/compiler/parser/Parser.y b/compiler/parser/Parser.y index d72aabd2e7..2c90086c56 100644 --- a/compiler/parser/Parser.y +++ b/compiler/parser/Parser.y @@ -575,8 +575,8 @@ rns :: { OrdList LRenaming } | rn { unitOL $1 } rn :: { LRenaming } - : modid 'as' modid { sLL $1 $> $ Renaming (unLoc $1) (unLoc $3) } - | modid { sL1 $1 $ Renaming (unLoc $1) (unLoc $1) } + : modid 'as' modid { sLL $1 $> $ Renaming $1 (Just $3) } + | modid { sL1 $1 $ Renaming $1 Nothing } unitbody :: { OrdList (LHsUnitDecl PackageName) } : '{' unitdecls '}' { $2 } @@ -847,9 +847,9 @@ optqualified :: { ([AddAnn],Bool) } : 'qualified' { ([mj AnnQualified $1],True) } | {- empty -} { ([],False) } -maybeas :: { ([AddAnn],Located (Maybe ModuleName)) } - : 'as' modid { ([mj AnnAs $1,mj AnnVal $2] - ,sLL $1 $> (Just (unLoc $2))) } +maybeas :: { ([AddAnn],Located (Maybe (Located ModuleName))) } + : 'as' modid { ([mj AnnAs $1] + ,sLL $1 $> (Just $2)) } | {- empty -} { ([],noLoc Nothing) } maybeimpspec :: { Located (Maybe (Bool, Located [LIE RdrName])) } diff --git a/compiler/rename/RnNames.hs b/compiler/rename/RnNames.hs index 549bccb80e..8da11bed1c 100644 --- a/compiler/rename/RnNames.hs +++ b/compiler/rename/RnNames.hs @@ -266,7 +266,7 @@ rnImportDecl this_mod ++ "Safe, Trustworthy or Unsafe")) let - qual_mod_name = as_mod `orElse` imp_mod_name + qual_mod_name = fmap unLoc as_mod `orElse` imp_mod_name imp_spec = ImpDeclSpec { is_mod = imp_mod_name, is_qual = qual_only, is_dloc = loc, is_as = qual_mod_name } diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs index a3cb955bbe..3fe42d23d4 100644 --- a/ghc/GHCi/UI.hs +++ b/ghc/GHCi/UI.hs @@ -749,7 +749,7 @@ getInfoForPrompt = do rev_imports = reverse imports -- rightmost are the most recent - myIdeclName d | Just m <- ideclAs d = m + myIdeclName d | Just m <- ideclAs d = unLoc m | otherwise = unLoc (ideclName d) modules_names = diff --git a/testsuite/tests/ghc-api/annotations/T10312.stdout b/testsuite/tests/ghc-api/annotations/T10312.stdout index 00f25444cc..c8dff60b10 100644 --- a/testsuite/tests/ghc-api/annotations/T10312.stdout +++ b/testsuite/tests/ghc-api/annotations/T10312.stdout @@ -12,7 +12,6 @@ ((Test10312.hs:9:1-30,AnnImport), [Test10312.hs:9:1-6]), ((Test10312.hs:9:1-30,AnnQualified), [Test10312.hs:9:8-16]), ((Test10312.hs:9:1-30,AnnSemi), [Test10312.hs:10:1]), -((Test10312.hs:9:1-30,AnnVal), [Test10312.hs:9:30]), ((Test10312.hs:10:1-27,AnnImport), [Test10312.hs:10:1-6]), ((Test10312.hs:10:1-27,AnnSemi), [Test10312.hs:11:1]), ((Test10312.hs:10:17-27,AnnCloseP), [Test10312.hs:10:27]), diff --git a/testsuite/tests/ghc-api/annotations/annotations.stdout b/testsuite/tests/ghc-api/annotations/annotations.stdout index e465403483..f0348058ba 100644 --- a/testsuite/tests/ghc-api/annotations/annotations.stdout +++ b/testsuite/tests/ghc-api/annotations/annotations.stdout @@ -19,8 +19,6 @@ (AK AnnotationLet.hs:5:1-32 AnnSemi = [AnnotationLet.hs:6:1]) -(AK AnnotationLet.hs:5:1-32 AnnVal = [AnnotationLet.hs:5:31-32]) - (AK AnnotationLet.hs:(7,1)-(11,12) AnnEqual = [AnnotationLet.hs:7:5]) (AK AnnotationLet.hs:(7,1)-(11,12) AnnFunId = [AnnotationLet.hs:7:1-3]) diff --git a/testsuite/tests/ghc-api/annotations/exampleTest.stdout b/testsuite/tests/ghc-api/annotations/exampleTest.stdout index a884f56a32..2cdef957d3 100644 --- a/testsuite/tests/ghc-api/annotations/exampleTest.stdout +++ b/testsuite/tests/ghc-api/annotations/exampleTest.stdout @@ -14,7 +14,6 @@ ((AnnotationTuple.hs:6:1-32,AnnImport), [AnnotationTuple.hs:6:1-6]), ((AnnotationTuple.hs:6:1-32,AnnQualified), [AnnotationTuple.hs:6:8-16]), ((AnnotationTuple.hs:6:1-32,AnnSemi), [AnnotationTuple.hs:7:1]), -((AnnotationTuple.hs:6:1-32,AnnVal), [AnnotationTuple.hs:6:31-32]), ((AnnotationTuple.hs:(8,1)-(11,14),AnnEqual), [AnnotationTuple.hs:8:5]), ((AnnotationTuple.hs:(8,1)-(11,14),AnnFunId), [AnnotationTuple.hs:8:1-3]), ((AnnotationTuple.hs:(8,1)-(11,14),AnnSemi), [AnnotationTuple.hs:13:1]), diff --git a/testsuite/tests/ghc-api/annotations/listcomps.stdout b/testsuite/tests/ghc-api/annotations/listcomps.stdout index 1c0b8e5ce4..3965257bb3 100644 --- a/testsuite/tests/ghc-api/annotations/listcomps.stdout +++ b/testsuite/tests/ghc-api/annotations/listcomps.stdout @@ -1,13 +1,13 @@ {ListComprehensions.hs:1:1, ListComprehensions.hs:6:8-25, ListComprehensions.hs:10:1-15, ListComprehensions.hs:10:8-15, ListComprehensions.hs:11:1-30, ListComprehensions.hs:11:18-25, - ListComprehensions.hs:12:1-27, ListComprehensions.hs:12:8-15, - ListComprehensions.hs:12:17-27, ListComprehensions.hs:12:18-26, - ListComprehensions.hs:13:1-25, ListComprehensions.hs:13:8-16, - ListComprehensions.hs:13:18-25, ListComprehensions.hs:13:19-24, - ListComprehensions.hs:17:1-16, ListComprehensions.hs:17:1-25, - ListComprehensions.hs:17:21-25, ListComprehensions.hs:17:22-24, - ListComprehensions.hs:18:1-16, + ListComprehensions.hs:11:30, ListComprehensions.hs:12:1-27, + ListComprehensions.hs:12:8-15, ListComprehensions.hs:12:17-27, + ListComprehensions.hs:12:18-26, ListComprehensions.hs:13:1-25, + ListComprehensions.hs:13:8-16, ListComprehensions.hs:13:18-25, + ListComprehensions.hs:13:19-24, ListComprehensions.hs:17:1-16, + ListComprehensions.hs:17:1-25, ListComprehensions.hs:17:21-25, + ListComprehensions.hs:17:22-24, ListComprehensions.hs:18:1-16, ListComprehensions.hs:(18,1)-(22,20), ListComprehensions.hs:(18,18)-(22,20), ListComprehensions.hs:(18,20)-(22,20), ListComprehensions.hs:18:22, @@ -55,8 +55,6 @@ (AK ListComprehensions.hs:11:1-30 AnnSemi = [ListComprehensions.hs:12:1]) -(AK ListComprehensions.hs:11:1-30 AnnVal = [ListComprehensions.hs:11:30]) - (AK ListComprehensions.hs:12:1-27 AnnImport = [ListComprehensions.hs:12:1-6]) (AK ListComprehensions.hs:12:1-27 AnnSemi = [ListComprehensions.hs:13:1]) diff --git a/testsuite/tests/ghc-api/annotations/parseTree.stdout b/testsuite/tests/ghc-api/annotations/parseTree.stdout index 46b1c4fbb4..092ba971d2 100644 --- a/testsuite/tests/ghc-api/annotations/parseTree.stdout +++ b/testsuite/tests/ghc-api/annotations/parseTree.stdout @@ -30,8 +30,6 @@ (AK AnnotationTuple.hs:6:1-32 AnnSemi = [AnnotationTuple.hs:7:1]) -(AK AnnotationTuple.hs:6:1-32 AnnVal = [AnnotationTuple.hs:6:31-32]) - (AK AnnotationTuple.hs:(8,1)-(11,14) AnnEqual = [AnnotationTuple.hs:8:5]) (AK AnnotationTuple.hs:(8,1)-(11,14) AnnFunId = [AnnotationTuple.hs:8:1-3]) diff --git a/utils/haddock b/utils/haddock -Subproject a5a51f99f42c7ee5e3bb4aeddf601b5f20a8813 +Subproject f4e355f7023057924161160ce75aeaaa3a8d991 |