-renameSig :: Sig RdrName -> RnMS (Sig Name)
--- ClassOpSig is renamed elsewhere.
-renameSig (Sig v ty src_loc)
- = pushSrcLocRn src_loc $
- lookupSigOccRn v `thenRn` \ new_v ->
- rnHsSigType (quotes (ppr v)) ty `thenRn` \ new_ty ->
- returnRn (Sig new_v new_ty src_loc)
-
-renameSig (SpecInstSig ty src_loc)
- = pushSrcLocRn src_loc $
- rnHsType (text "A SPECIALISE instance pragma") ty `thenRn` \ new_ty ->
- returnRn (SpecInstSig new_ty src_loc)
-
-renameSig (SpecSig v ty src_loc)
- = pushSrcLocRn src_loc $
- lookupSigOccRn v `thenRn` \ new_v ->
- rnHsSigType (quotes (ppr v)) ty `thenRn` \ new_ty ->
- returnRn (SpecSig new_v new_ty src_loc)
-
-renameSig (FixSig (FixitySig v fix src_loc))
- = pushSrcLocRn src_loc $
- lookupSigOccRn v `thenRn` \ new_v ->
- returnRn (FixSig (FixitySig new_v fix src_loc))
-
-renameSig (InlineSig v p src_loc)
- = pushSrcLocRn src_loc $
- lookupSigOccRn v `thenRn` \ new_v ->
- returnRn (InlineSig new_v p src_loc)
-
-renameSig (NoInlineSig v p src_loc)
- = pushSrcLocRn src_loc $
- lookupSigOccRn v `thenRn` \ new_v ->
- returnRn (NoInlineSig new_v p src_loc)
+renameSig :: Sig RdrName -> RnM (Sig Name)
+-- FixitSig is renamed elsewhere.
+renameSig (TypeSig v ty)
+ = lookupLocatedSigOccRn v `thenM` \ new_v ->
+ rnHsSigType (quotes (ppr v)) ty `thenM` \ new_ty ->
+ returnM (TypeSig new_v new_ty)
+
+renameSig (SpecInstSig ty)
+ = rnLHsType (text "A SPECIALISE instance pragma") ty `thenM` \ new_ty ->
+ returnM (SpecInstSig new_ty)
+
+renameSig (SpecSig v ty inl)
+ = lookupLocatedSigOccRn v `thenM` \ new_v ->
+ rnHsSigType (quotes (ppr v)) ty `thenM` \ new_ty ->
+ returnM (SpecSig new_v new_ty inl)
+
+renameSig (InlineSig v s)
+ = lookupLocatedSigOccRn v `thenM` \ new_v ->
+ returnM (InlineSig new_v s)
+\end{code}
+
+
+************************************************************************
+* *
+\subsection{Match}
+* *
+************************************************************************
+
+\begin{code}
+rnMatchGroup :: HsMatchContext Name -> MatchGroup RdrName -> RnM (MatchGroup Name, FreeVars)
+rnMatchGroup ctxt (MatchGroup ms _)
+ = mapFvRn (rnMatch ctxt) ms `thenM` \ (new_ms, ms_fvs) ->
+ returnM (MatchGroup new_ms placeHolderType, ms_fvs)
+
+rnMatch :: HsMatchContext Name -> LMatch RdrName -> RnM (LMatch Name, FreeVars)
+rnMatch ctxt = wrapLocFstM (rnMatch' ctxt)
+
+rnMatch' ctxt match@(Match pats maybe_rhs_sig grhss)
+ =
+ -- Deal with the rhs type signature
+ bindPatSigTyVarsFV rhs_sig_tys $
+ doptM Opt_GlasgowExts `thenM` \ opt_GlasgowExts ->
+ (case maybe_rhs_sig of
+ Nothing -> returnM (Nothing, emptyFVs)
+ Just ty | opt_GlasgowExts -> rnHsTypeFVs doc_sig ty `thenM` \ (ty', ty_fvs) ->
+ returnM (Just ty', ty_fvs)
+ | otherwise -> addLocErr ty patSigErr `thenM_`
+ returnM (Nothing, emptyFVs)
+ ) `thenM` \ (maybe_rhs_sig', ty_fvs) ->
+
+ -- Now the main event
+ rnPatsAndThen ctxt pats $ \ pats' ->
+ rnGRHSs ctxt grhss `thenM` \ (grhss', grhss_fvs) ->
+
+ returnM (Match pats' maybe_rhs_sig' grhss', grhss_fvs `plusFV` ty_fvs)
+ -- The bindPatSigTyVarsFV and rnPatsAndThen will remove the bound FVs
+ where
+ rhs_sig_tys = case maybe_rhs_sig of
+ Nothing -> []
+ Just ty -> [ty]
+ doc_sig = text "In a result type-signature"