+rnMatch match@(Match _ pats maybe_rhs_sig grhss)
+ = pushSrcLocRn (getMatchLoc match) $
+
+ -- Find the universally quantified type variables
+ -- in the pattern type signatures
+ getLocalNameEnv `thenRn` \ name_env ->
+ let
+ tyvars_in_sigs = rhs_sig_tyvars `unionLists` tyvars_in_pats
+ rhs_sig_tyvars = case maybe_rhs_sig of
+ Nothing -> []
+ Just ty -> extractHsTyRdrTyVars ty
+ tyvars_in_pats = extractPatsTyVars pats
+ forall_tyvars = filter (not . (`elemFM` name_env)) tyvars_in_sigs
+ doc_sig = text "a pattern type-signature"
+ doc_pats = text "in a pattern match"
+ in
+ bindTyVarsFVRn doc_sig (map UserTyVar forall_tyvars) $ \ sig_tyvars ->
+
+ -- Note that we do a single bindLocalsRn for all the
+ -- matches together, so that we spot the repeated variable in
+ -- f x x = 1
+ bindLocalsFVRn doc_pats (collectPatsBinders pats) $ \ new_binders ->
+
+ mapFvRn rnPat pats `thenRn` \ (pats', pat_fvs) ->
+ rnGRHSs grhss `thenRn` \ (grhss', grhss_fvs) ->
+ (case maybe_rhs_sig of
+ Nothing -> returnRn (Nothing, emptyFVs)
+ Just ty | opt_GlasgowExts -> rnHsType doc_sig ty `thenRn` \ (ty', ty_fvs) ->
+ returnRn (Just ty', ty_fvs)
+ | otherwise -> addErrRn (patSigErr ty) `thenRn_`
+ returnRn (Nothing, emptyFVs)
+ ) `thenRn` \ (maybe_rhs_sig', ty_fvs) ->