--- Then we must not choose (x::Int) as the matching variable!
-
-selectMatchVars :: [Pat Id] -> [Type] -> DsM [Id]
-selectMatchVars [] [] = return []
-selectMatchVars (p:ps) (ty:tys) = do { v <- selectMatchVar p ty
- ; vs <- selectMatchVars ps tys
- ; return (v:vs) }
-
-selectMatchVar (BangPat pat) pat_ty = selectMatchVar (unLoc pat) pat_ty
-selectMatchVar (LazyPat pat) pat_ty = selectMatchVar (unLoc pat) pat_ty
-selectMatchVar (VarPat var) pat_ty = try_for var pat_ty
-selectMatchVar (AsPat var pat) pat_ty = try_for (unLoc var) pat_ty
-selectMatchVar other_pat pat_ty = newSysLocalDs pat_ty -- OK, better make up one...
-
-try_for var pat_ty
- | idType var `tcEqType` pat_ty = returnDs var
- | otherwise = newSysLocalDs pat_ty
+-- Then we must not choose (x::Int) as the matching variable!
+-- And nowadays we won't, because the (x::Int) will be wrapped in a CoPat
+
+selectMatchVars :: [Pat Id] -> DsM [Id]
+selectMatchVars ps = mapM selectMatchVar ps
+
+selectMatchVar (BangPat pat) = selectMatchVar (unLoc pat)
+selectMatchVar (LazyPat pat) = selectMatchVar (unLoc pat)
+selectMatchVar (ParPat pat) = selectMatchVar (unLoc pat)
+selectMatchVar (VarPat var) = return var
+selectMatchVar (AsPat var pat) = return (unLoc var)
+selectMatchVar other_pat = newSysLocalDs (hsPatType other_pat)
+ -- OK, better make up one...