From f8f8449e1e54d0da1d16536070f18709b9e95af4 Mon Sep 17 00:00:00 2001 From: "simonpj@microsoft.com" Date: Wed, 3 Jan 2007 16:07:03 +0000 Subject: [PATCH] Be more relaxed about reporting ambiguous class methods (MERGE to STABLE branch, pls) This patch makes us a bit more relaxed about ambiguous class method types. See tc223 for an example. Reported by Yitzchak Gale --- compiler/typecheck/TcTyClsDecls.lhs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/typecheck/TcTyClsDecls.lhs b/compiler/typecheck/TcTyClsDecls.lhs index 5574b76..834bedc 100644 --- a/compiler/typecheck/TcTyClsDecls.lhs +++ b/compiler/typecheck/TcTyClsDecls.lhs @@ -24,6 +24,7 @@ import TcClassDcl import TcHsType import TcMType import TcType +import FunDeps import Type import Generics import Class @@ -1043,8 +1044,13 @@ checkValidClass cls ; checkValidType (FunSigCtxt op_name) tau -- Check that the type mentions at least one of - -- the class type variables - ; checkTc (any (`elemVarSet` tyVarsOfType tau) tyvars) + -- the class type variables...or at least one reachable + -- from one of the class variables. Example: tc223 + -- class Error e => Game b mv e | b -> mv e where + -- newBoard :: MonadState b m => m () + -- Here, MonadState has a fundep m->b, so newBoard is fine + ; let grown_tyvars = grow theta (mkVarSet tyvars) + ; checkTc (tyVarsOfType tau `intersectsVarSet` grown_tyvars) (noClassTyVarErr cls sel_id) -- Check that for a generic method, the type of -- 1.7.10.4