[commit: ghc] wip/fix-osx-ci: Small refactor (87f5755)

git at git.haskell.org git at git.haskell.org
Thu Jan 17 18:57:16 UTC 2019


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/fix-osx-ci
Link       : http://ghc.haskell.org/trac/ghc/changeset/87f5755d5c246c1cc9c8b7ed5c0d8fe30b6670cb/ghc

>---------------------------------------------------------------

commit 87f5755d5c246c1cc9c8b7ed5c0d8fe30b6670cb
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Thu Jan 10 12:08:47 2019 +0000

    Small refactor
    
    ...to use the same error message rather than duplicating it


>---------------------------------------------------------------

87f5755d5c246c1cc9c8b7ed5c0d8fe30b6670cb
 compiler/typecheck/TcInstDcls.hs | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/compiler/typecheck/TcInstDcls.hs b/compiler/typecheck/TcInstDcls.hs
index ba33fe2..fccf8b7 100644
--- a/compiler/typecheck/TcInstDcls.hs
+++ b/compiler/typecheck/TcInstDcls.hs
@@ -21,7 +21,7 @@ import TcBinds
 import TcTyClsDecls
 import TcTyDecls ( addTyConsToGblEnv )
 import TcClassDcl( tcClassDecl2, tcATDefault,
-                   HsSigFun, mkHsSigFun,
+                   HsSigFun, mkHsSigFun, badMethodErr,
                    findMethodBind, instantiateMethod )
 import TcSigs
 import TcRnMonad
@@ -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.
     -- See Note [Mismatched class methods and associated type families].
     checkMethBindMembership
-      = let bind_nms         = map unLoc $ collectMethodBinders binds
-            cls_meth_nms     = map (idName . fst) op_items
-            mismatched_meths = bind_nms `minusList` cls_meth_nms
-        in forM_ mismatched_meths $ \mismatched_meth ->
-             addErrTc $ hsep
-             [ text "Class", quotes (ppr (className clas))
-             , text "does not have a method", quotes (ppr mismatched_meth)]
+      = mapM_ (addErrTc . badMethodErr clas) mismatched_meths
+      where
+        bind_nms         = map unLoc $ collectMethodBinders binds
+        cls_meth_nms     = map (idName . fst) op_items
+        mismatched_meths = bind_nms `minusList` cls_meth_nms
 
 {-
 Note [Mismatched class methods and associated type families]



More information about the ghc-commits mailing list