X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcInstDcls.lhs;h=a76d87bdf234257b6e15fe8a919a8bca749c13ed;hb=67ed735fab12c12a1d48878d7bda33588c67fb78;hp=571cd7010430599119781e722344ef252dc1549e;hpb=d2ce0f52d42edf32bb9f13796e6ba6edba8bd516;p=ghc-hetmet.git diff --git a/compiler/typecheck/TcInstDcls.lhs b/compiler/typecheck/TcInstDcls.lhs index 571cd70..a76d87b 100644 --- a/compiler/typecheck/TcInstDcls.lhs +++ b/compiler/typecheck/TcInstDcls.lhs @@ -12,6 +12,7 @@ import HsSyn import TcBinds import TcTyClsDecls import TcClassDcl +import TcPat( addInlinePrags ) import TcRnMonad import TcMType import TcType @@ -19,6 +20,7 @@ import Inst import InstEnv import FamInst import FamInstEnv +import MkCore ( nO_METHOD_BINDING_ERROR_ID ) import TcDeriv import TcEnv import RnSource ( addTcgDUs ) @@ -834,11 +836,12 @@ tcInstanceMethods dfun_id clas tyvars dfun_ev_vars inst_tys ---------------------- tc_body :: Id -> Bool -> LHsBind Name -> TcM (TcId, LHsBind Id) tc_body sel_id generated_code rn_bind - = add_meth_ctxt generated_code rn_bind $ + = add_meth_ctxt sel_id generated_code rn_bind $ do { (meth_id, local_meth_id) <- mkMethIds clas tyvars dfun_ev_vars inst_tys sel_id - ; (meth_id1, spec_prags) <- tcPrags NonRecursive False True - meth_id (prag_fn (idName sel_id)) + ; let prags = prag_fn (idName sel_id) + ; meth_id1 <- addInlinePrags meth_id prags + ; spec_prags <- tcSpecPrags True meth_id prags ; bind <- tcInstanceMethodBody InstSkol tyvars dfun_ev_vars @@ -924,8 +927,8 @@ tcInstanceMethods dfun_id clas tyvars dfun_ev_vars inst_tys -- For instance decls that come from standalone deriving clauses -- we want to print out the full source code if there's an error -- because otherwise the user won't see the code at all - add_meth_ctxt generated_code rn_bind thing - | generated_code = addLandmarkErrCtxt (derivBindCtxt clas inst_tys rn_bind) thing + add_meth_ctxt sel_id generated_code rn_bind thing + | generated_code = addLandmarkErrCtxt (derivBindCtxt sel_id clas inst_tys rn_bind) thing | otherwise = thing @@ -1026,11 +1029,15 @@ mkMethIds clas tyvars dfun_ev_vars inst_tys sel_id wrapId :: HsWrapper -> id -> HsExpr id wrapId wrapper id = mkHsWrap wrapper (HsVar id) -derivBindCtxt :: Class -> [Type ] -> LHsBind Name -> SDoc -derivBindCtxt clas tys bind - = vcat [ ptext (sLit "When typechecking a standalone-derived method for") - <+> quotes (pprClassPred clas tys) <> colon - , nest 2 $ pprSetDepth AllTheWay $ ppr bind ] +derivBindCtxt :: Id -> Class -> [Type ] -> LHsBind Name -> SDoc +derivBindCtxt sel_id clas tys _bind + = vcat [ ptext (sLit "When typechecking the code for ") <+> quotes (ppr sel_id) + , nest 2 (ptext (sLit "in a standalone derived instance for") + <+> quotes (pprClassPred clas tys) <> colon) + , nest 2 $ ptext (sLit "To see the code I am typechecking, use -ddump-deriv") ] + +-- Too voluminous +-- , nest 2 $ pprSetDepth AllTheWay $ ppr bind ] warnMissingMethod :: Id -> TcM () warnMissingMethod sel_id