diff --git a/compiler/GHC/Hs/Binds.hs b/compiler/GHC/Hs/Binds.hs index 2651d1065ef117f5350925e5ef7decdca562860c..c14acb4c826a8574712e883a2b0bac2015aee721 100644 --- a/compiler/GHC/Hs/Binds.hs +++ b/compiler/GHC/Hs/Binds.hs @@ -853,7 +853,7 @@ ppr_sig (SCCFunSig (_, src) fn mlabel) GhcTc -> ppr fn ppr_sig (CompleteMatchSig (_, src) cs mty) = pragSrcBrackets src "{-# COMPLETE" - ((hsep (punctuate comma (map ppr_n (unLoc cs)))) + ((hsep (punctuate comma (map ppr_n cs))) <+> opt_sig) where opt_sig = maybe empty ((\t -> dcolon <+> ppr t) . unLoc) mty @@ -946,14 +946,6 @@ type instance Anno (HsBindLR (GhcPass idL) (GhcPass idR)) = SrcSpanAnnA type instance Anno (IPBind (GhcPass p)) = SrcSpanAnnA type instance Anno (Sig (GhcPass p)) = SrcSpanAnnA --- For CompleteMatchSig -type instance Anno [LocatedN RdrName] = SrcSpan -type instance Anno [LocatedN Name] = SrcSpan -type instance Anno [LocatedN Id] = SrcSpan - type instance Anno (FixitySig (GhcPass p)) = SrcSpanAnnA type instance Anno StringLiteral = EpAnnCO -type instance Anno (LocatedN RdrName) = SrcSpan -type instance Anno (LocatedN Name) = SrcSpan -type instance Anno (LocatedN Id) = SrcSpan diff --git a/compiler/GHC/HsToCore/Quote.hs b/compiler/GHC/HsToCore/Quote.hs index d4b15c792b5cb7103b0a7fbffca0e148f0f63511..0ba683482d16add8fc656c74e55bdfc116f75e9d 100644 --- a/compiler/GHC/HsToCore/Quote.hs +++ b/compiler/GHC/HsToCore/Quote.hs @@ -1159,11 +1159,11 @@ repPhases (ActiveAfter _ i) = do { MkC arg <- coreIntLit i ; dataCon' fromPhaseDataConName [arg] } repPhases _ = dataCon allPhasesDataConName -rep_complete_sig :: Located [LocatedN Name] +rep_complete_sig :: [LocatedN Name] -> Maybe (LocatedN Name) -> SrcSpan -> MetaM [(SrcSpan, Core (M TH.Dec))] -rep_complete_sig (L _ cls) mty loc +rep_complete_sig cls mty loc = do { mty' <- repMaybe nameTyConName lookupLOcc mty ; cls' <- repList nameTyConName lookupLOcc cls ; sig <- repPragComplete cls' mty' diff --git a/compiler/GHC/Iface/Ext/Ast.hs b/compiler/GHC/Iface/Ext/Ast.hs index 15e512cb10aab33990bf25b7acf0a43242a093e6..041933dfa17c9b3c64549fcabc57a7f77e919dd8 100644 --- a/compiler/GHC/Iface/Ext/Ast.hs +++ b/compiler/GHC/Iface/Ext/Ast.hs @@ -1812,9 +1812,8 @@ instance HiePass p => ToHie (SigContext (LocatedA (Sig (GhcPass p)))) where [ toHie $ (C Use) name , maybe (pure []) (locOnly . getLocA) mtxt ] - CompleteMatchSig _ (L ispan names) typ -> - [ locOnly ispan - , toHie $ map (C Use) names + CompleteMatchSig _ names typ -> + [ toHie $ map (C Use) names , toHie $ fmap (C Use) typ ] XSig _ -> [] diff --git a/compiler/GHC/Parser.y b/compiler/GHC/Parser.y index 9c5aa62fa37cd5026d001576cfb8ac946a9a3c23..b70c30d60e6ee27a9fc938ded73437ec0806a25b 100644 --- a/compiler/GHC/Parser.y +++ b/compiler/GHC/Parser.y @@ -3630,10 +3630,10 @@ con_list :: { Located (NonEmpty (LocatedN RdrName)) } con_list : con { sL1 $1 (pure $1) } | con ',' con_list {% sLL $1 $> . (:| toList (unLoc $3)) <\$> addTrailingCommaN $1 (gl $2) } -qcon_list :: { Located [LocatedN RdrName] } -qcon_list : qcon { sL1 $1 [$1] } +qcon_list :: { [LocatedN RdrName] } +qcon_list : qcon { [$1] } | qcon ',' qcon_list {% do { h <- addTrailingCommaN $1 (gl $2) - ; return (sLL $1 $> (h : unLoc $3)) }} + ; return (h : $3) }} -- See Note [ExplicitTuple] in GHC.Hs.Expr sysdcon_nolist :: { LocatedN DataCon } -- Wired in data constructors diff --git a/compiler/GHC/Rename/Bind.hs b/compiler/GHC/Rename/Bind.hs index 158b5a0b38c52f331bcf087bc0d4b51ff9ec5dfa..ff0c3b251dabbc5fe899e602218c45218f9efe1b 100644 --- a/compiler/GHC/Rename/Bind.hs +++ b/compiler/GHC/Rename/Bind.hs @@ -1138,7 +1138,7 @@ renameSig ctxt sig@(SCCFunSig (_, st) v s) -- COMPLETE Sigs can refer to imported IDs which is why we use -- lookupLocatedOccRn rather than lookupSigOccRn -renameSig _ctxt sig@(CompleteMatchSig (_, s) (L l bf) mty) +renameSig _ctxt sig@(CompleteMatchSig (_, s) bf mty) = do new_bf <- traverse lookupLocatedOccRn bf new_mty <- traverse lookupLocatedOccRn mty @@ -1147,7 +1147,7 @@ renameSig _ctxt sig@(CompleteMatchSig (_, s) (L l bf) mty) -- Why 'any'? See Note [Orphan COMPLETE pragmas] addErrCtxt (text "In" <+> ppr sig) $ failWithTc TcRnOrphanCompletePragma - return (CompleteMatchSig (noAnn, s) (L l new_bf) new_mty, emptyFVs) + return (CompleteMatchSig (noAnn, s) new_bf new_mty, emptyFVs) {- diff --git a/compiler/GHC/Tc/Gen/Bind.hs b/compiler/GHC/Tc/Gen/Bind.hs index 5b34e85b83918056724af57e61c22e919708a12c..4c97a3c99dfb8ab0e6b9a8db6a9e1bcb91613362 100644 --- a/compiler/GHC/Tc/Gen/Bind.hs +++ b/compiler/GHC/Tc/Gen/Bind.hs @@ -227,7 +227,7 @@ tcCompleteSigs sigs = -- combinations are invalid it will be found so at match sites. -- There it is also where we consider if the type of the pattern match is -- compatible with the result type constructor 'mb_tc'. - doOne (L loc c@(CompleteMatchSig (_ext, _src_txt) (L _ ns) mb_tc_nm)) + doOne (L loc c@(CompleteMatchSig (_ext, _src_txt) ns mb_tc_nm)) = fmap Just $ setSrcSpanA loc $ addErrCtxt (text "In" <+> ppr c) $ do cls <- mkUniqDSet <$> mapM (addLocM tcLookupConLike) ns mb_tc <- traverse @Maybe tcLookupLocatedTyCon mb_tc_nm diff --git a/compiler/GHC/ThToHs.hs b/compiler/GHC/ThToHs.hs index 407e5d8b23c1841e4fbd8060b46ce2a17332b04f..59266d70a2d3454a5887b38f2c9326fbfe178692 100644 --- a/compiler/GHC/ThToHs.hs +++ b/compiler/GHC/ThToHs.hs @@ -952,7 +952,7 @@ cvtPragmaD (LineP line file) ; return Nothing } cvtPragmaD (CompleteP cls mty) - = do { cls' <- wrapL $ mapM cNameN cls + = do { cls' <- mapM cNameN cls ; mty' <- traverse tconNameN mty ; returnJustLA $ Hs.SigD noExtField $ CompleteMatchSig (noAnn, NoSourceText) cls' mty' } diff --git a/compiler/Language/Haskell/Syntax/Binds.hs b/compiler/Language/Haskell/Syntax/Binds.hs index e8fcc96f7afcfa41f5417ff3daa6427a729d73c5..fca8a7b23ce5208018c66c24f07335f45423cbfd 100644 --- a/compiler/Language/Haskell/Syntax/Binds.hs +++ b/compiler/Language/Haskell/Syntax/Binds.hs @@ -487,7 +487,7 @@ data Sig pass -- complete matchings which, for example, arise from pattern -- synonym definitions. | CompleteMatchSig (XCompleteMatchSig pass) - (XRec pass [LIdP pass]) + [LIdP pass] (Maybe (LIdP pass)) | XSig !(XXSig pass)