Commit 56c26f5e authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Ben Gamari

Small refactor

...to use the same error message rather than duplicating it
parent 7b7b338b
...@@ -21,7 +21,7 @@ import TcBinds ...@@ -21,7 +21,7 @@ import TcBinds
import TcTyClsDecls import TcTyClsDecls
import TcTyDecls ( addTyConsToGblEnv ) import TcTyDecls ( addTyConsToGblEnv )
import TcClassDcl( tcClassDecl2, tcATDefault, import TcClassDcl( tcClassDecl2, tcATDefault,
HsSigFun, mkHsSigFun, HsSigFun, mkHsSigFun, badMethodErr,
findMethodBind, instantiateMethod ) findMethodBind, instantiateMethod )
import TcSigs import TcSigs
import TcRnMonad import TcRnMonad
...@@ -1539,13 +1539,11 @@ tcMethods dfun_id clas tyvars dfun_ev_vars inst_tys ...@@ -1539,13 +1539,11 @@ tcMethods dfun_id clas tyvars dfun_ev_vars inst_tys
-- Check if any method bindings do not correspond to the class. -- Check if any method bindings do not correspond to the class.
-- See Note [Mismatched class methods and associated type families]. -- See Note [Mismatched class methods and associated type families].
checkMethBindMembership checkMethBindMembership
= let bind_nms = map unLoc $ collectMethodBinders binds = mapM_ (addErrTc . badMethodErr clas) mismatched_meths
cls_meth_nms = map (idName . fst) op_items where
mismatched_meths = bind_nms `minusList` cls_meth_nms bind_nms = map unLoc $ collectMethodBinders binds
in forM_ mismatched_meths $ \mismatched_meth -> cls_meth_nms = map (idName . fst) op_items
addErrTc $ hsep mismatched_meths = bind_nms `minusList` cls_meth_nms
[ text "Class", quotes (ppr (className clas))
, text "does not have a method", quotes (ppr mismatched_meth)]
{- {-
Note [Mismatched class methods and associated type families] Note [Mismatched class methods and associated type families]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment