[project @ 2004-09-29 13:46:17 by simonpj]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcClassDcl.lhs
index 9ae343b..0c4f500 100644 (file)
@@ -13,7 +13,7 @@ module TcClassDcl ( tcClassSigs, tcClassDecl2,
 #include "HsVersions.h"
 
 import HsSyn
-import BasicTypes      ( RecFlag(..), NewOrData(..) )
+import BasicTypes      ( RecFlag(..) )
 import RnHsSyn         ( maybeGenericMatch, extractHsTyVars )
 import RnExpr          ( rnLExpr )
 import RnEnv           ( lookupTopBndrRn, lookupImportedName )
@@ -336,7 +336,13 @@ tcMethodBind
 
 tcMethodBind xtve inst_tyvars inst_theta avail_insts prags
             (sel_id, meth_id, meth_bind)
-  =    -- Check the bindings; first adding inst_tyvars to the envt
+  = recoverM (returnM emptyBag) $
+       -- If anything fails, recover returning no bindings.
+       -- This is particularly useful when checking the default-method binding of
+       -- a class decl. If we don't recover, we don't add the default method to
+       -- the type enviroment, and we get a tcLookup failure on $dmeth later.
+
+       -- Check the bindings; first adding inst_tyvars to the envt
        -- so that we don't quantify over them in nested places
      mkTcSig meth_id                           `thenM` \ meth_sig ->
 
@@ -523,7 +529,7 @@ mkDefMethRhs origin clas inst_tys sel_id loc NoDefMeth
        -- Need two splits because the  selector can have a type like
        --      forall a. Foo a => forall b. Eq b => ...
     (arg_tys, _) = tcSplitFunTys tau2
-    wild_pats   = [wildPat | ty <- arg_tys]
+    wild_pats   = [nlWildPat | ty <- arg_tys]
 
 mkDefMethRhs origin clas inst_tys sel_id loc GenDefMeth 
   =    -- A generic default method