X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=blobdiff_plain;f=compiler%2Ftypecheck%2FTcExpr.lhs;h=b844a2a0d371526bdb87217da6b64194540c5b7f;hp=1d83c8a90f1d9ca5fe3e3b28fcc48a1b124ef3ec;hb=bfd0c33d39619b580520e2d6e43d306380393ea6;hpb=183839ef216ee152d1c150641fed1120bc50f95a diff --git a/compiler/typecheck/TcExpr.lhs b/compiler/typecheck/TcExpr.lhs index 1d83c8a..b844a2a 100644 --- a/compiler/typecheck/TcExpr.lhs +++ b/compiler/typecheck/TcExpr.lhs @@ -785,7 +785,8 @@ instFun orig fun subst tv_theta_prs ; doStupidChecks fun ty_theta_prs' -- Now do normal instantiation - ; result <- go True fun ty_theta_prs' + ; method_sharing <- doptM Opt_MethodSharing + ; result <- go method_sharing True fun ty_theta_prs' ; traceTc (text "instFun result" <+> ppr result) ; return result } @@ -793,24 +794,24 @@ instFun orig fun subst tv_theta_prs subst_pr (tvs, theta) = (substTyVars subst tvs, substTheta subst theta) - go _ fun [] = do {traceTc (text "go _ fun [] returns" <+> ppr fun) ; return fun } + go _ _ fun [] = do {traceTc (text "go _ _ fun [] returns" <+> ppr fun) ; return fun } - go True (HsVar fun_id) ((tys,theta) : prs) - | want_method_inst theta + go method_sharing True (HsVar fun_id) ((tys,theta) : prs) + | want_method_inst method_sharing theta = do { traceTc (text "go (HsVar fun_id) ((tys,theta) : prs) | want_method_inst theta") ; meth_id <- newMethodWithGivenTy orig fun_id tys - ; go False (HsVar meth_id) prs } + ; go method_sharing False (HsVar meth_id) prs } -- Go round with 'False' to prevent further use -- of newMethod: see Note [Multiple instantiation] - go _ fun ((tys, theta) : prs) + go method_sharing _ fun ((tys, theta) : prs) = do { co_fn <- instCall orig tys theta ; traceTc (text "go yields co_fn" <+> ppr co_fn) - ; go False (HsWrap co_fn fun) prs } + ; go method_sharing False (HsWrap co_fn fun) prs } -- See Note [No method sharing] - want_method_inst theta = not (null theta) -- Overloaded - && not opt_NoMethodSharing + want_method_inst method_sharing theta = not (null theta) -- Overloaded + && method_sharing \end{code} Note [Multiple instantiation]