Fix error in Annotation filtering (fixes #70)

pull/75/head
Lennart Spitzner 2017-12-08 19:57:16 +01:00
parent 5bba918705
commit 39c48b33f1
3 changed files with 19 additions and 8 deletions

View File

@ -509,3 +509,7 @@ fmapuv f xs = G.generate (G.length xs) (f . (xs G.!))
#test parallellistcomp-workaround
cs0 = 0 : [ c / Interval n | c <- cs | n <- [1..] ]
#test issue 70
{-# LANGUAGE TemplateHaskell #-}
deriveFromJSON (unPrefix "assignPost") ''AssignmentPost

View File

@ -217,9 +217,16 @@ extractToplevelAnns
extractToplevelAnns lmod anns = output
where
(L _ (HsModule _ _ _ ldecls _ _)) = lmod
declMap :: Map ExactPrint.AnnKey ExactPrint.AnnKey
declMap = Map.unions $ ldecls <&> \ldecl ->
declMap1 :: Map ExactPrint.AnnKey ExactPrint.AnnKey
declMap1 = Map.unions $ ldecls <&> \ldecl ->
Map.fromSet (const (ExactPrint.mkAnnKey ldecl)) (foldedAnnKeys ldecl)
declMap2 :: Map ExactPrint.AnnKey ExactPrint.AnnKey
declMap2 =
Map.fromList
$ [ (captured, declMap1 Map.! k)
| (k, ExactPrint.Ann _ _ _ _ _ (Just captured)) <- Map.toList anns
]
declMap = declMap1 `Map.union` declMap2
modKey = ExactPrint.mkAnnKey lmod
output = groupMap (\k _ -> Map.findWithDefault modKey k declMap) anns