Alan Zimmerman pushed to branch wip/az/exactprint-annotation-rationalisation at Glasgow Haskell Compiler / GHC
Commits:
-
3555aee5
by Alan Zimmerman at 2026-07-02T23:04:24+01:00
-
b7559a99
by Alan Zimmerman at 2026-07-02T23:04:24+01:00
-
cedb075f
by Alan Zimmerman at 2026-07-02T23:04:24+01:00
18 changed files:
- compiler/GHC/Builtin/Utils.hs
- compiler/GHC/Hs/Decls.hs
- compiler/GHC/Hs/Decls/Overlap.hs
- compiler/GHC/Hs/Dump.hs
- compiler/GHC/Iface/Ext/Ast.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Iface/Warnings.hs
- compiler/GHC/Parser.y
- compiler/GHC/Parser/Annotation.hs
- compiler/GHC/Parser/PostProcess.hs
- compiler/GHC/Tc/Deriv.hs
- compiler/GHC/Tc/TyCl/Instance.hs
- compiler/GHC/Tc/Utils/Instantiate.hs
- compiler/GHC/ThToHs.hs
- compiler/GHC/Types/ForeignCall.hs
- compiler/GHC/Unit/Module/Warnings.hs
- utils/check-exact/ExactPrint.hs
- utils/haddock/haddock-api/src/Haddock/Types.hs
Changes:
| ... | ... | @@ -299,7 +299,7 @@ ghcPrimWarns = WarnSome |
| 299 | 299 | []
|
| 300 | 300 | where
|
| 301 | 301 | mk_txt msg =
|
| 302 | - DeprecatedTxt NoSourceText [noLocA $ WithHsDocIdentifiers (StringLiteral NoSourceText msg Nothing) []]
|
|
| 302 | + DeprecatedTxt (NoSourceText, noAnn) [noLocA $ WithHsDocIdentifiers (StringLiteral NoSourceText msg Nothing) []]
|
|
| 303 | 303 | mk_decl_dep (occ, msg) = (occ, mk_txt msg)
|
| 304 | 304 | |
| 305 | 305 | ghcPrimFixities :: [(OccName,Fixity)]
|
| ... | ... | @@ -1162,7 +1162,7 @@ cidDeprecation :: forall p. IsPass p |
| 1162 | 1162 | cidDeprecation = fmap unLoc . decl_deprecation (ghcPass @p)
|
| 1163 | 1163 | where
|
| 1164 | 1164 | decl_deprecation :: GhcPass p -> ClsInstDecl (GhcPass p)
|
| 1165 | - -> Maybe (LocatedP (WarningTxt (GhcPass p)))
|
|
| 1165 | + -> Maybe (LocatedA (WarningTxt (GhcPass p)))
|
|
| 1166 | 1166 | decl_deprecation GhcPs (ClsInstDecl{ cid_ext = (depr, _) } )
|
| 1167 | 1167 | = depr
|
| 1168 | 1168 | decl_deprecation GhcRn (ClsInstDecl{ cid_ext = depr })
|
| ... | ... | @@ -1272,20 +1272,25 @@ ppDerivStrategy mb = |
| 1272 | 1272 | Nothing -> empty
|
| 1273 | 1273 | Just (L _ ds) -> ppr ds
|
| 1274 | 1274 | |
| 1275 | -ppOverlapPragma :: Maybe (LocatedP (OverlapMode (GhcPass p))) -> SDoc
|
|
| 1275 | +ppOverlapPragma :: forall p. IsPass p => Maybe (LocatedA (OverlapMode (GhcPass p))) -> SDoc
|
|
| 1276 | 1276 | ppOverlapPragma mb =
|
| 1277 | 1277 | case mb of
|
| 1278 | 1278 | Nothing -> empty
|
| 1279 | - Just (L _ (NoOverlap s)) -> maybe_stext s "{-# NO_OVERLAP #-}"
|
|
| 1280 | - Just (L _ (Overlappable s)) -> maybe_stext s "{-# OVERLAPPABLE #-}"
|
|
| 1281 | - Just (L _ (Overlapping s)) -> maybe_stext s "{-# OVERLAPPING #-}"
|
|
| 1282 | - Just (L _ (Overlaps s)) -> maybe_stext s "{-# OVERLAPS #-}"
|
|
| 1283 | - Just (L _ (Incoherent s)) -> maybe_stext s "{-# INCOHERENT #-}"
|
|
| 1284 | - Just (L _ (NonCanonical s)) -> maybe_stext s "{-# INCOHERENT #-}" -- No surface syntax for NONCANONICAL yet
|
|
| 1279 | + Just (L _ (NoOverlap s)) -> maybe_stext (stext s) "{-# NO_OVERLAP #-}"
|
|
| 1280 | + Just (L _ (Overlappable s)) -> maybe_stext (stext s) "{-# OVERLAPPABLE #-}"
|
|
| 1281 | + Just (L _ (Overlapping s)) -> maybe_stext (stext s) "{-# OVERLAPPING #-}"
|
|
| 1282 | + Just (L _ (Overlaps s)) -> maybe_stext (stext s) "{-# OVERLAPS #-}"
|
|
| 1283 | + Just (L _ (Incoherent s)) -> maybe_stext (stext s) "{-# INCOHERENT #-}"
|
|
| 1284 | + Just (L _ (NonCanonical s)) -> maybe_stext (stext s) "{-# INCOHERENT #-}" -- No surface syntax for NONCANONICAL yet
|
|
| 1285 | 1285 | where
|
| 1286 | 1286 | maybe_stext NoSourceText alt = text alt
|
| 1287 | 1287 | maybe_stext (SourceText src) _ = ftext src <+> text "#-}"
|
| 1288 | 1288 | |
| 1289 | + stext :: XOverlapMode (GhcPass p) -> SourceText
|
|
| 1290 | + stext s = case (ghcPass @p, s) of
|
|
| 1291 | + (GhcPs, (s,_)) -> s
|
|
| 1292 | + (GhcRn, (s,_)) -> s
|
|
| 1293 | + (GhcTc, s) -> s
|
|
| 1289 | 1294 | |
| 1290 | 1295 | instance (OutputableBndrId p) => Outputable (InstDecl (GhcPass p)) where
|
| 1291 | 1296 | ppr (ClsInstD { cid_inst = decl }) = ppr decl
|
| ... | ... | @@ -1355,7 +1360,7 @@ derivDeprecation :: forall p. IsPass p |
| 1355 | 1360 | derivDeprecation = fmap unLoc . decl_deprecation (ghcPass @p)
|
| 1356 | 1361 | where
|
| 1357 | 1362 | decl_deprecation :: GhcPass p -> DerivDecl (GhcPass p)
|
| 1358 | - -> Maybe (LocatedP (WarningTxt (GhcPass p)))
|
|
| 1363 | + -> Maybe (LocatedA (WarningTxt (GhcPass p)))
|
|
| 1359 | 1364 | decl_deprecation GhcPs (DerivDecl{ deriv_ext = (depr, _) })
|
| 1360 | 1365 | = depr
|
| 1361 | 1366 | decl_deprecation GhcRn (DerivDecl{ deriv_ext = (depr, _) })
|
| ... | ... | @@ -1696,7 +1701,7 @@ type instance Anno (FunDep (GhcPass p)) = SrcSpanAnnA |
| 1696 | 1701 | type instance Anno (FamilyResultSig (GhcPass p)) = EpAnnCO
|
| 1697 | 1702 | type instance Anno (FamilyDecl (GhcPass p)) = SrcSpanAnnA
|
| 1698 | 1703 | type instance Anno (InjectivityAnn (GhcPass p)) = EpAnnCO
|
| 1699 | -type instance Anno (CType (GhcPass p)) = SrcSpanAnnP
|
|
| 1704 | +type instance Anno (CType (GhcPass p)) = SrcSpanAnnA
|
|
| 1700 | 1705 | type instance Anno (HsDerivingClause (GhcPass p)) = EpAnnCO
|
| 1701 | 1706 | type instance Anno (DerivClauseTys (GhcPass _)) = SrcSpanAnnA
|
| 1702 | 1707 | type instance Anno (StandaloneKindSig (GhcPass p)) = SrcSpanAnnA
|
| ... | ... | @@ -1711,7 +1716,7 @@ type instance Anno (ClsInstDecl (GhcPass p)) = SrcSpanAnnA |
| 1711 | 1716 | type instance Anno (InstDecl (GhcPass p)) = SrcSpanAnnA
|
| 1712 | 1717 | type instance Anno (DocDecl (GhcPass p)) = SrcSpanAnnA
|
| 1713 | 1718 | type instance Anno (DerivDecl (GhcPass p)) = SrcSpanAnnA
|
| 1714 | -type instance Anno (OverlapMode (GhcPass p)) = SrcSpanAnnP
|
|
| 1719 | +type instance Anno (OverlapMode (GhcPass p)) = SrcSpanAnnA
|
|
| 1715 | 1720 | type instance Anno (DerivStrategy (GhcPass p)) = EpAnnCO
|
| 1716 | 1721 | type instance Anno (DefaultDecl (GhcPass p)) = SrcSpanAnnA
|
| 1717 | 1722 | type instance Anno (ForeignDecl (GhcPass p)) = SrcSpanAnnA
|
| ... | ... | @@ -31,6 +31,8 @@ import GHC.Prelude |
| 31 | 31 | |
| 32 | 32 | import GHC.Hs.Extension
|
| 33 | 33 | |
| 34 | +import GHC.Parser.Annotation ( AnnPragma )
|
|
| 35 | + |
|
| 34 | 36 | import Language.Haskell.Syntax.Decls.Overlap
|
| 35 | 37 | import Language.Haskell.Syntax.Extension
|
| 36 | 38 | |
| ... | ... | @@ -70,11 +72,13 @@ instance NFData OverlapFlag where |
| 70 | 72 | instance Outputable OverlapFlag where
|
| 71 | 73 | ppr flag = ppr (overlapMode flag) <+> pprSafeOverlap (isSafeOverlap flag)
|
| 72 | 74 | |
| 73 | -type instance XOverlapMode (GhcPass _) = SourceText
|
|
| 75 | +type instance XOverlapMode GhcPs = (SourceText, AnnPragma)
|
|
| 76 | +type instance XOverlapMode GhcRn = (SourceText, AnnPragma)
|
|
| 77 | +type instance XOverlapMode GhcTc = SourceText
|
|
| 74 | 78 | |
| 75 | 79 | type instance XXOverlapMode (GhcPass _) = DataConCantHappen
|
| 76 | 80 | |
| 77 | -instance NFData (OverlapMode (GhcPass p)) where
|
|
| 81 | +instance NFData (OverlapMode GhcTc) where
|
|
| 78 | 82 | rnf = \case
|
| 79 | 83 | NoOverlap s -> rnf s
|
| 80 | 84 | Overlappable s -> rnf s
|
| ... | ... | @@ -83,7 +87,7 @@ instance NFData (OverlapMode (GhcPass p)) where |
| 83 | 87 | Incoherent s -> rnf s
|
| 84 | 88 | NonCanonical s -> rnf s
|
| 85 | 89 | |
| 86 | -instance Binary (OverlapMode (GhcPass p)) where
|
|
| 90 | +instance Binary (OverlapMode GhcTc) where
|
|
| 87 | 91 | put_ bh = \case
|
| 88 | 92 | NoOverlap s -> putByte bh 0 >> put_ bh s
|
| 89 | 93 | Overlaps s -> putByte bh 1 >> put_ bh s
|
| ... | ... | @@ -97,7 +97,6 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 |
| 97 | 97 | `extQ` bagName `extQ` bagRdrName `extQ` bagVar `extQ` nameSet
|
| 98 | 98 | `ext2Q` located
|
| 99 | 99 | `extQ` srcSpanAnnA
|
| 100 | - `extQ` srcSpanAnnP
|
|
| 101 | 100 | `extQ` srcSpanAnnN
|
| 102 | 101 | `extQ` srcSpanAnnBF
|
| 103 | 102 | |
| ... | ... | @@ -404,9 +403,6 @@ showAstData bs ba a0 = blankLine $$ showAstData' a0 |
| 404 | 403 | srcSpanAnnA :: EpAnn [TrailingAnn] -> SDoc
|
| 405 | 404 | srcSpanAnnA = locatedAnn'' (text "SrcSpanAnnA")
|
| 406 | 405 | |
| 407 | - srcSpanAnnP :: EpAnn AnnPragma -> SDoc
|
|
| 408 | - srcSpanAnnP = locatedAnn'' (text "SrcSpanAnnP")
|
|
| 409 | - |
|
| 410 | 406 | srcSpanAnnN :: EpAnn NameAnn -> SDoc
|
| 411 | 407 | srcSpanAnnN = locatedAnn'' (text "SrcSpanAnnN")
|
| 412 | 408 |
| ... | ... | @@ -1750,7 +1750,7 @@ instance ToHie (RScoped (LocatedAn NoEpAnns (DerivStrategy GhcRn))) where |
| 1750 | 1750 | NewtypeStrategy _ -> []
|
| 1751 | 1751 | ViaStrategy s -> [ toHie (TS (ResolvedScopes [sc]) s) ]
|
| 1752 | 1752 | |
| 1753 | -instance ToHie (LocatedP (OverlapMode GhcRn)) where
|
|
| 1753 | +instance ToHie (LocatedA (OverlapMode GhcRn)) where
|
|
| 1754 | 1754 | toHie (L span _) = locOnly (locA span)
|
| 1755 | 1755 | |
| 1756 | 1756 | instance ToHie (LocatedA (ConDecl GhcRn)) where
|
| ... | ... | @@ -83,7 +83,7 @@ import GHC.Core.TyCon ( Role (..), Injectivity(..), tyConBndrVisForAllTyFlag ) |
| 83 | 83 | import GHC.Core.DataCon (SrcStrictness(..), SrcUnpackedness(..))
|
| 84 | 84 | import GHC.Builtin.Types ( constraintKindTyConName )
|
| 85 | 85 | import GHC.Stg.EnforceEpt.TagSig
|
| 86 | -import GHC.Parser.Annotation (noLocA)
|
|
| 86 | +import GHC.Parser.Annotation (noLocA, noAnn)
|
|
| 87 | 87 | import GHC.Hs.Extension ( GhcPass, GhcRn, GhcTc )
|
| 88 | 88 | import GHC.Hs.Decls.Overlap ( OverlapFlag )
|
| 89 | 89 | import GHC.Hs.Doc ( WithHsDocIdentifiers(..) )
|
| ... | ... | @@ -664,8 +664,8 @@ fromIfaceWarnings = \case |
| 664 | 664 | |
| 665 | 665 | fromIfaceWarningTxt :: IfaceWarningTxt -> WarningTxt GhcRn
|
| 666 | 666 | fromIfaceWarningTxt = \case
|
| 667 | - IfWarningTxt src mb_cat strs -> WarningTxt src (noLocA . fromWarningCategory <$> mb_cat) (noLocA <$> map fromIfaceStringLiteralWithNames strs)
|
|
| 668 | - IfDeprecatedTxt src strs -> DeprecatedTxt src (noLocA <$> map fromIfaceStringLiteralWithNames strs)
|
|
| 667 | + IfWarningTxt src mb_cat strs -> WarningTxt (src, noAnn) (noLocA . fromWarningCategory <$> mb_cat) (noLocA <$> map fromIfaceStringLiteralWithNames strs)
|
|
| 668 | + IfDeprecatedTxt src strs -> DeprecatedTxt (src, noAnn) (noLocA <$> map fromIfaceStringLiteralWithNames strs)
|
|
| 669 | 669 | |
| 670 | 670 | fromIfaceStringLiteralWithNames :: (IfaceStringLiteral, [IfExtName]) -> WithHsDocIdentifiers StringLiteral GhcRn
|
| 671 | 671 | fromIfaceStringLiteralWithNames (str, names) = WithHsDocIdentifiers (fromIfaceStringLiteral str) (map noLoc names)
|
| ... | ... | @@ -23,12 +23,11 @@ toIfaceWarnings (WarnSome vs ds) = IfWarnSome vs' ds' |
| 23 | 23 | ds' = [(occ, toIfaceWarningTxt txt) | (occ, txt) <- ds]
|
| 24 | 24 | |
| 25 | 25 | toIfaceWarningTxt :: WarningTxt GhcRn -> IfaceWarningTxt
|
| 26 | -toIfaceWarningTxt (WarningTxt src mb_cat strs) = IfWarningTxt src (unLoc . iwc_wc . unLoc <$> mb_cat) (map (toIfaceStringLiteralWithNames . unLoc) strs)
|
|
| 27 | -toIfaceWarningTxt (DeprecatedTxt src strs) = IfDeprecatedTxt src (map (toIfaceStringLiteralWithNames . unLoc) strs)
|
|
| 26 | +toIfaceWarningTxt (WarningTxt (src, _) mb_cat strs) = IfWarningTxt src (unLoc . iwc_wc . unLoc <$> mb_cat) (map (toIfaceStringLiteralWithNames . unLoc) strs)
|
|
| 27 | +toIfaceWarningTxt (DeprecatedTxt (src, _) strs) = IfDeprecatedTxt src (map (toIfaceStringLiteralWithNames . unLoc) strs)
|
|
| 28 | 28 | |
| 29 | 29 | toIfaceStringLiteralWithNames :: WithHsDocIdentifiers StringLiteral GhcRn -> (IfaceStringLiteral, [IfExtName])
|
| 30 | 30 | toIfaceStringLiteralWithNames (WithHsDocIdentifiers src names) = (toIfaceStringLiteral src, map unLoc names)
|
| 31 | 31 | |
| 32 | 32 | toIfaceStringLiteral :: StringLiteral -> IfaceStringLiteral
|
| 33 | 33 | toIfaceStringLiteral (StringLiteral sl fs _) = IfStringLiteral sl fs |
| 34 | - |
| ... | ... | @@ -1469,15 +1469,15 @@ inst_decl :: { LInstDecl GhcPs } |
| 1469 | 1469 | (fmap reverse $7)
|
| 1470 | 1470 | (AnnDataDefn [] [] NoEpTok tnewtype tdata (epTok $2) dcolon twhere oc cc NoEpTok)}}
|
| 1471 | 1471 | |
| 1472 | -overlap_pragma :: { Maybe (LocatedP (OverlapMode GhcPs)) }
|
|
| 1473 | - : '{-# OVERLAPPABLE' '#-}' {% fmap Just $ amsr (sLL $1 $> (Overlappable (getOVERLAPPABLE_PRAGs $1)))
|
|
| 1474 | - (AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
|
|
| 1475 | - | '{-# OVERLAPPING' '#-}' {% fmap Just $ amsr (sLL $1 $> (Overlapping (getOVERLAPPING_PRAGs $1)))
|
|
| 1476 | - (AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
|
|
| 1477 | - | '{-# OVERLAPS' '#-}' {% fmap Just $ amsr (sLL $1 $> (Overlaps (getOVERLAPS_PRAGs $1)))
|
|
| 1478 | - (AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
|
|
| 1479 | - | '{-# INCOHERENT' '#-}' {% fmap Just $ amsr (sLL $1 $> (Incoherent (getINCOHERENT_PRAGs $1)))
|
|
| 1480 | - (AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn) }
|
|
| 1472 | +overlap_pragma :: { Maybe (LocatedA (OverlapMode GhcPs)) }
|
|
| 1473 | + : '{-# OVERLAPPABLE' '#-}' {% fmap Just $ amsA' (sLL $1 $> (Overlappable (getOVERLAPPABLE_PRAGs $1,
|
|
| 1474 | + AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn))) }
|
|
| 1475 | + | '{-# OVERLAPPING' '#-}' {% fmap Just $ amsA' (sLL $1 $> (Overlapping (getOVERLAPPING_PRAGs $1,
|
|
| 1476 | + AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn))) }
|
|
| 1477 | + | '{-# OVERLAPS' '#-}' {% fmap Just $ amsA' (sLL $1 $> (Overlaps (getOVERLAPS_PRAGs $1,
|
|
| 1478 | + AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn))) }
|
|
| 1479 | + | '{-# INCOHERENT' '#-}' {% fmap Just $ amsA' (sLL $1 $> (Incoherent (getINCOHERENT_PRAGs $1,
|
|
| 1480 | + AnnPragma (glR $1) (epTok $2) noAnn noAnn noAnn noAnn noAnn))) }
|
|
| 1481 | 1481 | | {- empty -} { Nothing }
|
| 1482 | 1482 | |
| 1483 | 1483 | deriv_strategy_no_via :: { LDerivStrategy GhcPs }
|
| ... | ... | @@ -1705,15 +1705,17 @@ datafam_inst_hdr :: { Located (Maybe (LHsContext GhcPs), HsOuterFamEqnTyVarBndrs |
| 1705 | 1705 | | type { sL1 $1 (Nothing, mkHsOuterImplicit, $1) }
|
| 1706 | 1706 | |
| 1707 | 1707 | |
| 1708 | -capi_ctype :: { Maybe (LocatedP (CType GhcPs)) }
|
|
| 1708 | +capi_ctype :: { Maybe (LocatedA (CType GhcPs)) }
|
|
| 1709 | 1709 | capi_ctype : '{-# CTYPE' STRING STRING '#-}'
|
| 1710 | - {% fmap Just $ amsr (sLL $1 $> (mkCType (getCTYPEs $1) (getSTRINGs $3) (Just (Header (getSTRINGs $2) (getSTRING $2)))
|
|
| 1711 | - (getSTRING $3)))
|
|
| 1712 | - (AnnPragma (glR $1) (epTok $4) noAnn (glR $2) (glR $3) noAnn noAnn) }
|
|
| 1710 | + {% fmap Just $ amsA' (sLL $1 $> (mkCType (getCTYPEs $1) (getSTRINGs $3)
|
|
| 1711 | + (AnnPragma (glR $1) (epTok $4) noAnn (glR $2) (glR $3) noAnn noAnn)
|
|
| 1712 | + (Just (Header (getSTRINGs $2) (getSTRING $2)))
|
|
| 1713 | + (getSTRING $3)))}
|
|
| 1713 | 1714 | |
| 1714 | 1715 | | '{-# CTYPE' STRING '#-}'
|
| 1715 | - {% fmap Just $ amsr (sLL $1 $> (mkCType (getCTYPEs $1) (getSTRINGs $2) Nothing (getSTRING $2)))
|
|
| 1716 | - (AnnPragma (glR $1) (epTok $3) noAnn noAnn (glR $2) noAnn noAnn) }
|
|
| 1716 | + {% fmap Just $ amsA' (sLL $1 $> (mkCType (getCTYPEs $1) (getSTRINGs $2)
|
|
| 1717 | + (AnnPragma (glR $1) (epTok $3) noAnn noAnn (glR $2) noAnn noAnn)
|
|
| 1718 | + Nothing (getSTRING $2)))}
|
|
| 1717 | 1719 | |
| 1718 | 1720 | | { Nothing }
|
| 1719 | 1721 | |
| ... | ... | @@ -2073,11 +2075,13 @@ to varid (used for rule_vars), 'checkRuleTyVarBndrNames' must be updated. |
| 2073 | 2075 | |
| 2074 | 2076 | maybe_warning_pragma :: { Maybe (LWarningTxt GhcPs) }
|
| 2075 | 2077 | : '{-# DEPRECATED' strings '#-}'
|
| 2076 | - {% fmap Just $ amsr (sLL $1 $> $ DeprecatedTxt (getDEPRECATED_PRAGs $1) (map stringLiteralToHsDocWst $ snd $ unLoc $2))
|
|
| 2077 | - (AnnPragma (glR $1) (epTok $3) (fst $ unLoc $2) noAnn noAnn noAnn noAnn) }
|
|
| 2078 | + {% fmap Just $ amsA' (sLL $1 $> $
|
|
| 2079 | + DeprecatedTxt (getDEPRECATED_PRAGs $1, AnnPragma (glR $1) (epTok $3) (fst $ unLoc $2) noAnn noAnn noAnn noAnn)
|
|
| 2080 | + (map stringLiteralToHsDocWst $ snd $ unLoc $2))}
|
|
| 2078 | 2081 | | '{-# WARNING' warning_category strings '#-}'
|
| 2079 | - {% fmap Just $ amsr (sLL $1 $> $ WarningTxt (getWARNING_PRAGs $1) $2 (map stringLiteralToHsDocWst $ snd $ unLoc $3))
|
|
| 2080 | - (AnnPragma (glR $1) (epTok $4) (fst $ unLoc $3) noAnn noAnn noAnn noAnn)}
|
|
| 2082 | + {% fmap Just $ amsA' (sLL $1 $> $
|
|
| 2083 | + WarningTxt (getWARNING_PRAGs $1, AnnPragma (glR $1) (epTok $4) (fst $ unLoc $3) noAnn noAnn noAnn noAnn)
|
|
| 2084 | + $2 (map stringLiteralToHsDocWst $ snd $ unLoc $3))}
|
|
| 2081 | 2085 | | {- empty -} { Nothing }
|
| 2082 | 2086 | |
| 2083 | 2087 | warning_category :: { Maybe (LocatedE (InWarningCategory GhcPs)) }
|
| ... | ... | @@ -2106,7 +2110,7 @@ warning :: { OrdList (LWarnDecl GhcPs) } |
| 2106 | 2110 | : warning_category namespace_spec namelist strings
|
| 2107 | 2111 | {% fmap unitOL $ amsA' (L (comb4 $1 $2 $3 $4)
|
| 2108 | 2112 | (Warning (fst $ unLoc $4) (unLoc $2) (unLoc $3)
|
| 2109 | - (WarningTxt NoSourceText $1 (map stringLiteralToHsDocWst $ snd $ unLoc $4)))) }
|
|
| 2113 | + (WarningTxt (NoSourceText, noAnn) $1 (map stringLiteralToHsDocWst $ snd $ unLoc $4)))) }
|
|
| 2110 | 2114 | |
| 2111 | 2115 | namespace_spec :: { Located (NamespaceSpecifier GhcPs) }
|
| 2112 | 2116 | : 'type' { sL1 $1 $ TypeNamespaceSpecifier (epTok $1) }
|
| ... | ... | @@ -2134,7 +2138,7 @@ deprecations :: { OrdList (LWarnDecl GhcPs) } |
| 2134 | 2138 | deprecation :: { OrdList (LWarnDecl GhcPs) }
|
| 2135 | 2139 | : namespace_spec namelist strings
|
| 2136 | 2140 | {% fmap unitOL $ amsA' (sL (comb3 $1 $2 $>) $ (Warning (fst $ unLoc $3) (unLoc $1) (unLoc $2)
|
| 2137 | - (DeprecatedTxt NoSourceText $ map stringLiteralToHsDocWst $ snd $ unLoc $3))) }
|
|
| 2141 | + (DeprecatedTxt (NoSourceText, noAnn) $ map stringLiteralToHsDocWst $ snd $ unLoc $3))) }
|
|
| 2138 | 2142 | |
| 2139 | 2143 | strings :: { Located ((EpToken "[", EpToken "]"),[Located StringLiteral]) }
|
| 2140 | 2144 | : STRING { sL1 $1 (noAnn,[L (gl $1) (getStringLiteral $1)]) }
|
| ... | ... | @@ -27,9 +27,9 @@ module GHC.Parser.Annotation ( |
| 27 | 27 | EpAnnCO,
|
| 28 | 28 | |
| 29 | 29 | -- ** Annotations in 'GenLocated'
|
| 30 | - LocatedA, LocatedN, LocatedAn, LocatedP,
|
|
| 30 | + LocatedA, LocatedN, LocatedAn,
|
|
| 31 | 31 | LocatedE, LocatedBF,
|
| 32 | - SrcSpanAnnA, SrcSpanAnnP, SrcSpanAnnN,
|
|
| 32 | + SrcSpanAnnA, SrcSpanAnnN,
|
|
| 33 | 33 | SrcSpanAnnBF,
|
| 34 | 34 | |
| 35 | 35 | -- ** Annotation data types used in 'GenLocated'
|
| ... | ... | @@ -428,7 +428,6 @@ emptyComments = EpaComments [] |
| 428 | 428 | type LocatedA = GenLocated SrcSpanAnnA
|
| 429 | 429 | type LocatedN = GenLocated SrcSpanAnnN
|
| 430 | 430 | |
| 431 | -type LocatedP = GenLocated SrcSpanAnnP
|
|
| 432 | 431 | type LocatedBF = GenLocated SrcSpanAnnBF
|
| 433 | 432 | |
| 434 | 433 | -- | Annotation for items appearing in a list. They can have one or
|
| ... | ... | @@ -439,7 +438,6 @@ type SrcSpanAnnA = EpAnn [TrailingAnn] |
| 439 | 438 | -- on the context, such as backticks.
|
| 440 | 439 | type SrcSpanAnnN = EpAnn NameAnn
|
| 441 | 440 | |
| 442 | -type SrcSpanAnnP = EpAnn AnnPragma
|
|
| 443 | 441 | type SrcSpanAnnBF = EpAnn AnnBooleanFormula
|
| 444 | 442 | |
| 445 | 443 | type LocatedE = GenLocated EpaLocation
|
| ... | ... | @@ -229,7 +229,7 @@ mkClassDecl loc' (L _ (mcxt, tycl_hdr)) fds where_cls layout annsIn |
| 229 | 229 | mkTyData :: SrcSpan
|
| 230 | 230 | -> Bool
|
| 231 | 231 | -> NewOrData
|
| 232 | - -> Maybe (LocatedP (CType GhcPs))
|
|
| 232 | + -> Maybe (LocatedA (CType GhcPs))
|
|
| 233 | 233 | -> Located (Maybe (LHsContext GhcPs), LHsType GhcPs)
|
| 234 | 234 | -> Maybe (LHsKind GhcPs)
|
| 235 | 235 | -> [LConDecl GhcPs]
|
| ... | ... | @@ -251,7 +251,7 @@ mkTyData loc' is_type_data new_or_data cType (L _ (mcxt, tycl_hdr)) |
| 251 | 251 | tcdDataDefn = defn,
|
| 252 | 252 | tcdModifiers = [] })) }
|
| 253 | 253 | |
| 254 | -mkDataDefn :: Maybe (LocatedP (CType GhcPs))
|
|
| 254 | +mkDataDefn :: Maybe (LocatedA (CType GhcPs))
|
|
| 255 | 255 | -> Maybe (LHsContext GhcPs)
|
| 256 | 256 | -> Maybe (LHsKind GhcPs)
|
| 257 | 257 | -> DataDefnCons (LConDecl GhcPs)
|
| ... | ... | @@ -326,7 +326,7 @@ mkTyFamInstEqn loc bndrs lhs rhs annEq |
| 326 | 326 | |
| 327 | 327 | mkDataFamInst :: SrcSpan
|
| 328 | 328 | -> NewOrData
|
| 329 | - -> Maybe (LocatedP (CType GhcPs))
|
|
| 329 | + -> Maybe (LocatedA (CType GhcPs))
|
|
| 330 | 330 | -> (Maybe ( LHsContext GhcPs), HsOuterFamEqnTyVarBndrs GhcPs
|
| 331 | 331 | , LHsType GhcPs)
|
| 332 | 332 | -> Maybe (LHsKind GhcPs)
|
| ... | ... | @@ -11,7 +11,7 @@ |
| 11 | 11 | {-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
|
| 12 | 12 | |
| 13 | 13 | -- | Handles @deriving@ clauses on @data@ declarations.
|
| 14 | -module GHC.Tc.Deriv ( tcDeriving, DerivInfo(..) ) where
|
|
| 14 | +module GHC.Tc.Deriv ( tcDeriving, DerivInfo(..), tcOverlapMode ) where
|
|
| 15 | 15 | |
| 16 | 16 | import GHC.Prelude
|
| 17 | 17 | |
| ... | ... | @@ -776,12 +776,12 @@ deriveStandalone (L loc (DerivDecl (warn, _) deriv_ty mb_lderiv_strat overlap_mo |
| 776 | 776 | |
| 777 | 777 | tcOverlapMode :: OverlapMode GhcRn -> OverlapMode GhcTc
|
| 778 | 778 | tcOverlapMode = \case
|
| 779 | - NoOverlap s -> NoOverlap s
|
|
| 780 | - Overlappable s -> Overlappable s
|
|
| 781 | - Overlapping s -> Overlapping s
|
|
| 782 | - Overlaps s -> Overlaps s
|
|
| 783 | - Incoherent s -> Incoherent s
|
|
| 784 | - NonCanonical s -> NonCanonical s
|
|
| 779 | + NoOverlap s -> NoOverlap (fst s)
|
|
| 780 | + Overlappable s -> Overlappable (fst s)
|
|
| 781 | + Overlapping s -> Overlapping (fst s)
|
|
| 782 | + Overlaps s -> Overlaps (fst s)
|
|
| 783 | + Incoherent s -> Incoherent (fst s)
|
|
| 784 | + NonCanonical s -> NonCanonical (fst s)
|
|
| 785 | 785 | |
| 786 | 786 | -- Typecheck the type in a standalone deriving declaration.
|
| 787 | 787 | --
|
| ... | ... | @@ -559,7 +559,7 @@ tcClsInstDecl (L loc (ClsInstDecl { cid_ext = lwarn |
| 559 | 559 | -- Dfun location is that of instance *header*
|
| 560 | 560 | |
| 561 | 561 | ; let warn = fmap unLoc lwarn
|
| 562 | - ; ispec <- newClsInst (fmap unLoc overlap_mode) dfun_name
|
|
| 562 | + ; ispec <- newClsInst (fmap (tcOverlapMode . unLoc) overlap_mode) dfun_name
|
|
| 563 | 563 | tyvars theta clas inst_tys warn
|
| 564 | 564 | |
| 565 | 565 | ; let inst_binds = InstBindings
|
| ... | ... | @@ -905,7 +905,7 @@ hasFixedRuntimeRepRes std_nm user_expr ty = mapM_ do_check mb_arity |
| 905 | 905 | ************************************************************************
|
| 906 | 906 | -}
|
| 907 | 907 | |
| 908 | -getOverlapFlag :: Maybe (OverlapMode (GhcPass p)) -- User pragma if any
|
|
| 908 | +getOverlapFlag :: Maybe (OverlapMode GhcTc) -- User pragma if any
|
|
| 909 | 909 | -> TcM OverlapFlag
|
| 910 | 910 | -- Construct the OverlapFlag from the global module flags,
|
| 911 | 911 | -- but if the overlap_mode argument is (Just m),
|
| ... | ... | @@ -929,9 +929,9 @@ getOverlapFlag overlap_mode_prag |
| 929 | 929 | |
| 930 | 930 | overlap_mode
|
| 931 | 931 | | Just m <- overlap_mode_prag = m
|
| 932 | - | incoherent_ok = Incoherent NoSourceText
|
|
| 933 | - | overlap_ok = Overlaps NoSourceText
|
|
| 934 | - | otherwise = NoOverlap NoSourceText
|
|
| 932 | + | incoherent_ok = Incoherent noAnn
|
|
| 933 | + | overlap_ok = Overlaps noAnn
|
|
| 934 | + | otherwise = NoOverlap noAnn
|
|
| 935 | 935 | |
| 936 | 936 | -- final_overlap_mode: the `-fspecialise-incoherents` flag controls the
|
| 937 | 937 | -- meaning of the `Incoherent` overlap mode: as either an Incoherent overlap
|
| ... | ... | @@ -957,7 +957,7 @@ tcGetInsts :: TcM [ClsInst] |
| 957 | 957 | -- Gets the local class instances.
|
| 958 | 958 | tcGetInsts = fmap tcg_insts getGblEnv
|
| 959 | 959 | |
| 960 | -newClsInst :: Maybe (OverlapMode (GhcPass p)) -- User pragma
|
|
| 960 | +newClsInst :: Maybe (OverlapMode GhcTc) -- User pragma
|
|
| 961 | 961 | -> Name -> [TyVar] -> ThetaType
|
| 962 | 962 | -> Class -> [Type] -> Maybe (WarningTxt GhcRn) -> TcM ClsInst
|
| 963 | 963 | newClsInst overlap_mode dfun_name tvs theta clas tys warn
|
| ... | ... | @@ -337,7 +337,6 @@ cvtDec (ClassD ctxt cl tvs fds decs) |
| 337 | 337 | }
|
| 338 | 338 | |
| 339 | 339 | cvtDec (InstanceD o ctxt ty decs)
|
| 340 | - -- = do { (binds', sigs', fams', ats', adts') <- cvt_ci_decs InstanceDecl decs
|
|
| 341 | 340 | = do { decs' <- cvt_ci_decs InstanceDecl decs
|
| 342 | 341 | ; let (fams', decls') = partitionWith is_fam_decl decs'
|
| 343 | 342 | ; for_ (nonEmpty fams') $ \ bad_fams ->
|
| ... | ... | @@ -356,10 +355,10 @@ cvtDec (InstanceD o ctxt ty decs) |
| 356 | 355 | where
|
| 357 | 356 | overlap pragma =
|
| 358 | 357 | case pragma of
|
| 359 | - TH.Overlaps -> Hs.Overlaps (SourceText $ fsLit "{-# OVERLAPS")
|
|
| 360 | - TH.Overlappable -> Hs.Overlappable (SourceText $ fsLit "{-# OVERLAPPABLE")
|
|
| 361 | - TH.Overlapping -> Hs.Overlapping (SourceText $ fsLit "{-# OVERLAPPING")
|
|
| 362 | - TH.Incoherent -> Hs.Incoherent (SourceText $ fsLit "{-# INCOHERENT")
|
|
| 358 | + TH.Overlaps -> Hs.Overlaps (SourceText $ fsLit "{-# OVERLAPS", noAnn)
|
|
| 359 | + TH.Overlappable -> Hs.Overlappable (SourceText $ fsLit "{-# OVERLAPPABLE", noAnn)
|
|
| 360 | + TH.Overlapping -> Hs.Overlapping (SourceText $ fsLit "{-# OVERLAPPING", noAnn)
|
|
| 361 | + TH.Incoherent -> Hs.Incoherent (SourceText $ fsLit "{-# INCOHERENT", noAnn)
|
|
| 363 | 362 | |
| 364 | 363 | |
| 365 | 364 |
| ... | ... | @@ -109,6 +109,7 @@ import Data.Data (Data) |
| 109 | 109 | import Data.Functor ((<&>))
|
| 110 | 110 | |
| 111 | 111 | import Control.DeepSeq (NFData(..))
|
| 112 | +import GHC.Parser.Annotation (AnnPragma, noAnn)
|
|
| 112 | 113 | |
| 113 | 114 | {-
|
| 114 | 115 | ************************************************************************
|
| ... | ... | @@ -213,11 +214,11 @@ instance Outputable CCallSpec where |
| 213 | 214 | |
| 214 | 215 | defaultCType :: String -> CType (GhcPass p)
|
| 215 | 216 | defaultCType =
|
| 216 | - CType (CTypeGhc NoSourceText NoSourceText) Nothing . fsLit
|
|
| 217 | + CType (CTypeGhc NoSourceText NoSourceText noAnn) Nothing . fsLit
|
|
| 217 | 218 | |
| 218 | -mkCType :: SourceText -> SourceText -> Maybe (Header (GhcPass p)) -> FastString -> CType (GhcPass p)
|
|
| 219 | -mkCType x y m =
|
|
| 220 | - CType (CTypeGhc x y) m
|
|
| 219 | +mkCType :: SourceText -> SourceText -> AnnPragma -> Maybe (Header (GhcPass p)) -> FastString -> CType (GhcPass p)
|
|
| 220 | +mkCType x y ann m =
|
|
| 221 | + CType (CTypeGhc x y ann) m
|
|
| 221 | 222 | |
| 222 | 223 | typeCheckCType :: CType GhcRn -> CType GhcTc
|
| 223 | 224 | typeCheckCType (CType x y z) = CType x (typeCheckHeader <$> y) z
|
| ... | ... | @@ -302,6 +303,7 @@ data StaticTargetGhc = StaticTargetGhc |
| 302 | 303 | data CTypeGhc = CTypeGhc
|
| 303 | 304 | { cTypeSourceText :: SourceText
|
| 304 | 305 | , cTypeOtherText :: SourceText
|
| 306 | + , cTypeAnn :: AnnPragma
|
|
| 305 | 307 | }
|
| 306 | 308 | deriving (Data, Eq)
|
| 307 | 309 | |
| ... | ... | @@ -350,12 +352,15 @@ instance Binary CTypeGhc where |
| 350 | 352 | put_ bh ct = do
|
| 351 | 353 | put_ bh (cTypeSourceText ct)
|
| 352 | 354 | put_ bh (cTypeOtherText ct)
|
| 355 | + put_ bh (cTypeAnn ct)
|
|
| 353 | 356 | get bh = do
|
| 354 | 357 | str1 <- get bh
|
| 355 | 358 | str2 <- get bh
|
| 359 | + ann <- get bh
|
|
| 356 | 360 | return $ CTypeGhc
|
| 357 | 361 | { cTypeSourceText = str1
|
| 358 | 362 | , cTypeOtherText = str2
|
| 363 | + , cTypeAnn = ann
|
|
| 359 | 364 | }
|
| 360 | 365 | |
| 361 | 366 | instance NFData StaticTargetGhc where
|
| ... | ... | @@ -156,8 +156,8 @@ warningTxtSame w1 w2 |
| 156 | 156 | instance Outputable (InWarningCategory (GhcPass pass)) where
|
| 157 | 157 | ppr (InWarningCategory _ wt) = text "in" <+> doubleQuotes (ppr wt)
|
| 158 | 158 | |
| 159 | -type instance XDeprecatedTxt (GhcPass _) = SourceText
|
|
| 160 | -type instance XWarningTxt (GhcPass _) = SourceText
|
|
| 159 | +type instance XDeprecatedTxt (GhcPass _) = (SourceText, AnnPragma)
|
|
| 160 | +type instance XWarningTxt (GhcPass _) = (SourceText, AnnPragma)
|
|
| 161 | 161 | type instance XXWarningTxt (GhcPass _) = DataConCantHappen
|
| 162 | 162 | type instance XInWarningCategory (GhcPass _) = (EpToken "in", SourceText)
|
| 163 | 163 | type instance XXInWarningCategory (GhcPass _) = DataConCantHappen
|
| ... | ... | @@ -165,7 +165,7 @@ type instance XXInWarningCategory (GhcPass _) = DataConCantHappen |
| 165 | 165 | type instance Anno (WithHsDocIdentifiers StringLiteral pass) = EpaLocation
|
| 166 | 166 | type instance Anno (InWarningCategory (GhcPass pass)) = EpaLocation
|
| 167 | 167 | type instance Anno (WarningCategory) = EpaLocation
|
| 168 | -type instance Anno (WarningTxt (GhcPass pass)) = SrcSpanAnnP
|
|
| 168 | +type instance Anno (WarningTxt (GhcPass pass)) = SrcSpanAnnA
|
|
| 169 | 169 | |
| 170 | 170 | deriving stock instance Eq (WarningTxt GhcPs)
|
| 171 | 171 | deriving stock instance Eq (WarningTxt GhcRn)
|
| ... | ... | @@ -190,15 +190,15 @@ deriving instance Uniquable WarningCategory |
| 190 | 190 | instance Outputable (WarningTxt (GhcPass pass)) where
|
| 191 | 191 | ppr (WarningTxt lsrc mcat ws)
|
| 192 | 192 | = case lsrc of
|
| 193 | - NoSourceText -> pp_ws ws
|
|
| 194 | - SourceText src -> ftext src <+> ctg_doc <+> pp_ws ws <+> text "#-}"
|
|
| 193 | + (NoSourceText, _) -> pp_ws ws
|
|
| 194 | + (SourceText src, _) -> ftext src <+> ctg_doc <+> pp_ws ws <+> text "#-}"
|
|
| 195 | 195 | where
|
| 196 | 196 | ctg_doc = maybe empty (\ctg -> ppr ctg) mcat
|
| 197 | 197 | |
| 198 | 198 | ppr (DeprecatedTxt lsrc ds)
|
| 199 | 199 | = case lsrc of
|
| 200 | - NoSourceText -> pp_ws ds
|
|
| 201 | - SourceText src -> ftext src <+> pp_ws ds <+> text "#-}"
|
|
| 200 | + (NoSourceText, _) -> pp_ws ds
|
|
| 201 | + (SourceText src, _) -> ftext src <+> pp_ws ds <+> text "#-}"
|
|
| 202 | 202 | |
| 203 | 203 | pp_ws :: [LocatedE (WithHsDocIdentifiers StringLiteral pass)] -> SDoc
|
| 204 | 204 | pp_ws [l] = ppr $ unLoc l
|
| ... | ... | @@ -1558,26 +1558,26 @@ instance ExactPrint ModuleName where |
| 1558 | 1558 | |
| 1559 | 1559 | -- ---------------------------------------------------------------------
|
| 1560 | 1560 | |
| 1561 | -instance ExactPrint (LocatedP (WarningTxt GhcPs)) where
|
|
| 1562 | - getAnnotationEntry = entryFromLocatedA
|
|
| 1563 | - setAnnotationAnchor = setAnchorAn
|
|
| 1561 | +instance ExactPrint (WarningTxt GhcPs) where
|
|
| 1562 | + getAnnotationEntry _ = NoEntryVal
|
|
| 1563 | + setAnnotationAnchor a _ _ _ = a
|
|
| 1564 | 1564 | |
| 1565 | - exact (L (EpAnn l (AnnPragma o c (os,cs) l1 l2 t m) css) (WarningTxt src mb_cat ws)) = do
|
|
| 1565 | + exact (WarningTxt (src, AnnPragma o c (os,cs) l1 l2 t m) mb_cat ws) = do
|
|
| 1566 | 1566 | o' <- markAnnOpen'' o src "{-# WARNING"
|
| 1567 | 1567 | mb_cat' <- markAnnotated mb_cat
|
| 1568 | 1568 | os' <- markEpToken os
|
| 1569 | 1569 | ws' <- mapM markAnnotated ws
|
| 1570 | 1570 | cs' <- markEpToken cs
|
| 1571 | 1571 | c' <- markEpToken c
|
| 1572 | - return (L (EpAnn l (AnnPragma o' c' (os',cs') l1 l2 t m) css) (WarningTxt src mb_cat' ws'))
|
|
| 1572 | + return (WarningTxt (src, AnnPragma o' c' (os',cs') l1 l2 t m) mb_cat' ws')
|
|
| 1573 | 1573 | |
| 1574 | - exact (L (EpAnn l (AnnPragma o c (os,cs) l1 l2 t m) css) (DeprecatedTxt src ws)) = do
|
|
| 1574 | + exact (DeprecatedTxt (src, AnnPragma o c (os,cs) l1 l2 t m) ws) = do
|
|
| 1575 | 1575 | o' <- markAnnOpen'' o src "{-# DEPRECATED"
|
| 1576 | 1576 | os' <- markEpToken os
|
| 1577 | 1577 | ws' <- mapM markAnnotated ws
|
| 1578 | 1578 | cs' <- markEpToken cs
|
| 1579 | 1579 | c' <- markEpToken c
|
| 1580 | - return (L (EpAnn l (AnnPragma o' c' (os',cs') l1 l2 t m) css) (DeprecatedTxt src ws'))
|
|
| 1580 | + return (DeprecatedTxt (src, AnnPragma o' c' (os',cs') l1 l2 t m) ws')
|
|
| 1581 | 1581 | |
| 1582 | 1582 | instance Typeable p => ExactPrint (InWarningCategory (GhcPass p)) where
|
| 1583 | 1583 | getAnnotationEntry _ = NoEntryVal
|
| ... | ... | @@ -2248,40 +2248,40 @@ instance ExactPrint (TyFamInstDecl GhcPs) where |
| 2248 | 2248 | |
| 2249 | 2249 | -- ---------------------------------------------------------------------
|
| 2250 | 2250 | |
| 2251 | -instance Typeable p => ExactPrint (LocatedP (OverlapMode (GhcPass p))) where
|
|
| 2252 | - getAnnotationEntry = entryFromLocatedA
|
|
| 2253 | - setAnnotationAnchor = setAnchorAn
|
|
| 2251 | +instance ExactPrint (OverlapMode GhcPs) where
|
|
| 2252 | + getAnnotationEntry _ = NoEntryVal
|
|
| 2253 | + setAnnotationAnchor a _ _ _ = a
|
|
| 2254 | 2254 | |
| 2255 | 2255 | -- NOTE: NoOverlap is only used in the typechecker
|
| 2256 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (NoOverlap src)) = do
|
|
| 2256 | + exact (NoOverlap (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2257 | 2257 | o' <- markAnnOpen'' o src "{-# NO_OVERLAP"
|
| 2258 | 2258 | c' <- markEpToken c
|
| 2259 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (NoOverlap src))
|
|
| 2259 | + return (NoOverlap (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2260 | 2260 | |
| 2261 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (Overlappable src)) = do
|
|
| 2261 | + exact (Overlappable (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2262 | 2262 | o' <- markAnnOpen'' o src "{-# OVERLAPPABLE"
|
| 2263 | 2263 | c' <- markEpToken c
|
| 2264 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Overlappable src))
|
|
| 2264 | + return (Overlappable (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2265 | 2265 | |
| 2266 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (Overlapping src)) = do
|
|
| 2266 | + exact (Overlapping (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2267 | 2267 | o' <- markAnnOpen'' o src "{-# OVERLAPPING"
|
| 2268 | 2268 | c' <- markEpToken c
|
| 2269 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Overlapping src))
|
|
| 2269 | + return (Overlapping (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2270 | 2270 | |
| 2271 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (Overlaps src)) = do
|
|
| 2271 | + exact (Overlaps (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2272 | 2272 | o' <- markAnnOpen'' o src "{-# OVERLAPS"
|
| 2273 | 2273 | c' <- markEpToken c
|
| 2274 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Overlaps src))
|
|
| 2274 | + return (Overlaps (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2275 | 2275 | |
| 2276 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (Incoherent src)) = do
|
|
| 2276 | + exact (Incoherent (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2277 | 2277 | o' <- markAnnOpen'' o src "{-# INCOHERENT"
|
| 2278 | 2278 | c' <- markEpToken c
|
| 2279 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Incoherent src))
|
|
| 2279 | + return (Incoherent (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2280 | 2280 | |
| 2281 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (NonCanonical src)) = do
|
|
| 2281 | + exact (NonCanonical (src, AnnPragma o c s l1 l2 t m)) = do
|
|
| 2282 | 2282 | o' <- markAnnOpen'' o src "{-# INCOHERENT"
|
| 2283 | 2283 | c' <- markEpToken c
|
| 2284 | - return (L (EpAnn l (AnnPragma o' c' s l1 l2 t m) cs) (Incoherent src))
|
|
| 2284 | + return (Incoherent (src, AnnPragma o' c' s l1 l2 t m))
|
|
| 2285 | 2285 | |
| 2286 | 2286 | -- ---------------------------------------------------------------------
|
| 2287 | 2287 | |
| ... | ... | @@ -4407,13 +4407,14 @@ instance ExactPrint t => ExactPrint (HsModifierOf t GhcPs) where |
| 4407 | 4407 | |
| 4408 | 4408 | -- ---------------------------------------------------------------------
|
| 4409 | 4409 | |
| 4410 | -instance Typeable p => ExactPrint (LocatedP (CType (GhcPass p))) where
|
|
| 4411 | - getAnnotationEntry = entryFromLocatedA
|
|
| 4412 | - setAnnotationAnchor = setAnchorAn
|
|
| 4410 | +instance Typeable p => ExactPrint (CType (GhcPass p)) where
|
|
| 4411 | + getAnnotationEntry _ = NoEntryVal
|
|
| 4412 | + setAnnotationAnchor a _ _ _ = a
|
|
| 4413 | 4413 | |
| 4414 | - exact (L (EpAnn l (AnnPragma o c s l1 l2 t m) cs) (CType ext mh ct)) = do
|
|
| 4414 | + exact (CType ext mh ct) = do
|
|
| 4415 | 4415 | let stp = cTypeSourceText ext
|
| 4416 | 4416 | stct = cTypeOtherText ext
|
| 4417 | + AnnPragma o c s l1 l2 t m = cTypeAnn ext
|
|
| 4417 | 4418 | o' <- markAnnOpen'' o stp "{-# CTYPE"
|
| 4418 | 4419 | l1' <- case mh of
|
| 4419 | 4420 | Nothing -> return l1
|
| ... | ... | @@ -4421,7 +4422,7 @@ instance Typeable p => ExactPrint (LocatedP (CType (GhcPass p))) where |
| 4421 | 4422 | printStringAtAA l1 (toSourceTextWithSuffix srcH "" "")
|
| 4422 | 4423 | l2' <- printStringAtAA l2 (toSourceTextWithSuffix stct (unpackFS ct) "")
|
| 4423 | 4424 | c' <- markEpToken c
|
| 4424 | - return (L (EpAnn l (AnnPragma o' c' s l1' l2' t m) cs) (CType ext mh ct))
|
|
| 4425 | + return (CType (ext { cTypeAnn = AnnPragma o' c' s l1' l2' t m }) mh ct)
|
|
| 4425 | 4426 | |
| 4426 | 4427 | -- ---------------------------------------------------------------------
|
| 4427 | 4428 |
| ... | ... | @@ -834,8 +834,8 @@ type instance Anno (FamilyResultSig DocNameI) = EpAnn NoEpAnns |
| 834 | 834 | type instance Anno (HsOuterTyVarBndrs Specificity DocNameI) = SrcSpanAnnA
|
| 835 | 835 | type instance Anno (HsSigType DocNameI) = SrcSpanAnnA
|
| 836 | 836 | type instance Anno (BooleanFormula DocNameI) = SrcSpanAnnBF
|
| 837 | -type instance Anno (OverlapMode DocNameI) = EpAnn AnnPragma
|
|
| 838 | -type instance Anno (CType DocNameI) = EpAnn AnnPragma
|
|
| 837 | +type instance Anno (OverlapMode DocNameI) = SrcSpanAnnA
|
|
| 838 | +type instance Anno (CType DocNameI) = SrcSpanAnnA
|
|
| 839 | 839 | type instance Anno (Header DocNameI) = EpAnn AnnPragma
|
| 840 | 840 | type instance Anno (HsModifierOf (LocatedA (HsType DocNameI)) DocNameI) = SrcSpanAnnA
|
| 841 | 841 | type instance Anno (HsContextDetails DocNameI a) = SrcSpanAnnA
|