Skip to content

Commit 65ca7c4

Browse files
updates for compatibility with GHC HEAD
1 parent edb58be commit 65ca7c4

File tree

8 files changed

+31
-17
lines changed

8 files changed

+31
-17
lines changed

src/Config/Haskell.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@ errorOn (L pos val) msg = exitMessageImpure $
8585
errorOnComment :: LEpaComment -> String -> b
8686
errorOnComment c@(L s _) msg = exitMessageImpure $
8787
let isMultiline = isCommentMultiline c in
88-
showSrcSpan (RealSrcSpan (anchor s) GHC.Data.Strict.Nothing) ++
88+
showSrcSpan (RealSrcSpan (epaLocationRealSrcSpan s) GHC.Data.Strict.Nothing) ++
8989
": Error while reading hint file, " ++ msg ++ "\n" ++
9090
(if isMultiline then "{-" else "--") ++ commentText c ++ (if isMultiline then "-}" else "")

src/GHC/Util/ApiAnnotation.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ languagePragmas ps =
107107
-- Given a list of flags, make a GHC options pragma.
108108
mkFlags :: NoCommentsLocation -> [String] -> LEpaComment
109109
mkFlags anc flags =
110-
L anc $ EpaComment (EpaBlockComment ("{-# " ++ "OPTIONS_GHC " ++ unwords flags ++ " #-}")) (anchor anc)
110+
L anc $ EpaComment (EpaBlockComment ("{-# " ++ "OPTIONS_GHC " ++ unwords flags ++ " #-}")) (epaLocationRealSrcSpan anc)
111111

112112
mkLanguagePragmas :: NoCommentsLocation -> [String] -> LEpaComment
113113
mkLanguagePragmas anc exts =
114-
L anc $ EpaComment (EpaBlockComment ("{-# " ++ "LANGUAGE " ++ intercalate ", " exts ++ " #-}")) (anchor anc)
114+
L anc $ EpaComment (EpaBlockComment ("{-# " ++ "LANGUAGE " ++ intercalate ", " exts ++ " #-}")) (epaLocationRealSrcSpan anc)

src/GHC/Util/Brackets.hs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ instance Brackets (LocatedA (HsExpr GhcPs)) where
5959
_ -> False
6060
where
6161
isNegativeLit (HsInt _ i) = il_neg i
62-
isNegativeLit (HsRat _ f _) = fl_neg f
6362
isNegativeLit (HsFloatPrim _ f) = fl_neg f
6463
isNegativeLit (HsDoublePrim _ f) = fl_neg f
6564
isNegativeLit (HsIntPrim _ x) = x < 0
6665
isNegativeLit (HsInt64Prim _ x) = x < 0
67-
isNegativeLit (HsInteger _ x _) = x < 0
6866
isNegativeLit _ = False
6967
isNegativeOverLit OverLit {ol_val=HsIntegral i} = il_neg i
7068
isNegativeOverLit OverLit {ol_val=HsFractional f} = fl_neg f
@@ -131,8 +129,6 @@ instance Brackets (LocatedA (Pat GhcPs)) where
131129
isSignedLit HsInt{} = True
132130
isSignedLit HsIntPrim{} = True
133131
isSignedLit HsInt64Prim{} = True
134-
isSignedLit HsInteger{} = True
135-
isSignedLit HsRat{} = True
136132
isSignedLit HsFloatPrim{} = True
137133
isSignedLit HsDoublePrim{} = True
138134
isSignedLit _ = False

src/GHC/Util/SrcLoc.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import Data.Generics.Uniplate.DataOnly
2020
-- Get the 'SrcSpan' out of a value located by an 'NoCommentsLocation'
2121
-- (e.g. comments).
2222
getAncLoc :: GenLocated NoCommentsLocation a -> SrcSpan
23-
getAncLoc o = RealSrcSpan (GHC.Parser.Annotation.anchor (GHC.Types.SrcLoc.getLoc o)) GHC.Data.Strict.Nothing
23+
getAncLoc o = RealSrcSpan (GHC.Parser.Annotation.epaLocationRealSrcSpan (GHC.Types.SrcLoc.getLoc o)) GHC.Data.Strict.Nothing
2424

2525
-- 'stripLocs x' is 'x' with all contained source locs replaced by
2626
-- 'noSrcSpan'.

src/GHC/Util/Unify.hs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ unify' nm root x y
120120
| Just (x :: EpAnn AnnExplicitSum) <- cast x = Just mempty
121121
| Just (x :: EpAnn AnnFieldLabel) <- cast x = Just mempty
122122
| Just (x :: EpAnn (AnnList [EpToken ","])) <- cast x = Just mempty
123+
| Just (x :: EpAnn (AnnList ())) <- cast x = Just mempty
124+
| Just (x :: EpAnn (AnnList (EpToken "where"))) <- cast x = Just mempty
125+
| Just (x :: EpAnn (AnnList (EpToken "hiding", [EpToken ","]))) <- cast x = Just mempty
123126
| Just (x :: EpAnn AnnListItem) <- cast x = Just mempty
124127
| Just (x :: EpAnn AnnParen) <- cast x = Just mempty
125128
| Just (x :: EpAnn AnnPragma) <- cast x = Just mempty
@@ -135,18 +138,33 @@ unify' nm root x y
135138
| Just (x :: EpAnn HsRuleAnn) <- cast x = Just mempty
136139
| Just (x :: EpAnn NameAnn) <- cast x = Just mempty
137140
| Just (x :: EpAnn NoEpAnns) <- cast x = Just mempty
138-
| Just (x :: EpAnn [AddEpAnn]) <- cast x = Just mempty
139-
| Just (x :: EpAnn (AddEpAnn, AddEpAnn)) <- cast x = Just mempty
140-
| Just (x :: EpToken "let") <- cast x = Just mempty
141-
| Just (x :: EpToken "in") <- cast x = Just mempty
142-
| Just (x :: EpToken "@") <- cast x = Just mempty
141+
| Just (x :: EpToken "|") <- cast x = Just mempty
142+
| Just (x :: EpToken ",") <- cast x = Just mempty
143+
| Just (x :: EpToken ";") <- cast x = Just mempty
144+
| Just (x :: EpToken "`") <- cast x = Just mempty
145+
| Just (x :: EpToken ".") <- cast x = Just mempty
146+
| Just (x :: EpToken "\\") <- cast x = Just mempty
143147
| Just (x :: EpToken "(") <- cast x = Just mempty
144148
| Just (x :: EpToken ")") <- cast x = Just mempty
149+
| Just (x :: EpToken "@") <- cast x = Just mempty
150+
| Just (x :: EpToken "#-}") <- cast x = Just mempty
151+
| Just (x :: EpToken "if") <- cast x = Just mempty
152+
| Just (x :: EpToken "then") <- cast x = Just mempty
153+
| Just (x :: EpToken "else") <- cast x = Just mempty
154+
| Just (x :: EpToken "case") <- cast x = Just mempty
155+
| Just (x :: EpToken "of") <- cast x = Just mempty
156+
| Just (x :: EpToken "in") <- cast x = Just mempty
145157
| Just (x :: EpToken "type") <- cast x = Just mempty
146158
| Just (x :: EpToken "%") <- cast x = Just mempty
147159
| Just (x :: EpToken "%1") <- cast x = Just mempty
148-
| Just (x :: EpToken "") <- cast x = Just mempty
160+
| Just (x :: EpToken "proc") <- cast x = Just mempty
161+
| Just (x :: EpToken "static") <- cast x = Just mempty
162+
| Just (x :: EpToken "qualified") <- cast x = Just mempty
163+
| Just (x :: EpToken "safe") <- cast x = Just mempty
164+
| Just (x :: EpToken "as") <- cast x = Just mempty
165+
| Just (x :: EpToken "import") <- cast x = Just mempty
149166
| Just (x :: EpUniToken "->" "") <- cast x = Just mempty
167+
| Just (x :: EpUniToken "::" "") <- cast x = Just mempty
150168
| Just (x :: TokenLocation) <- cast y = Just mempty
151169
| Just (y :: SrcSpan) <- cast y = Just mempty
152170

src/Hint/Comment.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ commentHint _ m = concatMap chk (ghcComments m)
4646
grab :: String -> LEpaComment -> String -> Idea
4747
grab msg o@(L pos _) s2 =
4848
let s1 = commentText o
49-
loc = RealSrcSpan (anchor pos) GHC.Data.Strict.Nothing
49+
loc = RealSrcSpan (epaLocationRealSrcSpan pos) GHC.Data.Strict.Nothing
5050
in
5151
rawIdea Suggestion msg loc (f s1) (Just $ f s2) [] (refact loc)
5252
where f s = if isCommentMultiline o then "{-" ++ s ++ "-}" else "--" ++ s

src/Hint/Extensions.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ extensionsHint :: ModuHint
301301
extensionsHint _ x =
302302
[
303303
rawIdea Hint.Type.Warning "Unused LANGUAGE pragma"
304-
(RealSrcSpan (anchor sl) GHC.Data.Strict.Nothing)
304+
(RealSrcSpan (epaLocationRealSrcSpan sl) GHC.Data.Strict.Nothing)
305305
(comment_ (mkLanguagePragmas sl exts))
306306
(Just newPragma)
307307
( [RequiresExtension (show gone) | (_, Just x) <- before \\ after, gone <- Map.findWithDefault [] x disappear] ++

src/Hint/Pattern.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ import Data.Either
6969
import Refact.Types hiding (RType(Pattern, Match), SrcSpan)
7070
import Refact.Types qualified as R (RType(Pattern, Match), SrcSpan)
7171

72-
import GHC.Hs hiding(asPattern)
72+
import GHC.Hs hiding (asPattern)
7373
import GHC.Types.SrcLoc
7474
import GHC.Types.Name.Reader
7575
import GHC.Types.Name.Occurrence

0 commit comments

Comments
 (0)