Commit 42c6263f authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

Avoid recursive use of immSuperClasses

In fixing Trac #11480 I had omitted to deal with FunDeps.oclose,
which was making recursive use of immSuperClasses, and hence
going into a loop in the recursive case.

Solution: use transSuperClasses, which takes care not to.
parent 746764cc
......@@ -23,7 +23,7 @@ import Name
import Var
import Class
import Type
import TcType( immSuperClasses )
import TcType( transSuperClasses )
import Unify
import InstEnv
import VarSet
......@@ -510,18 +510,17 @@ oclose preds fixed_tvs
tv_fds :: [(TyCoVarSet,TyCoVarSet)]
tv_fds = [ (tyCoVarsOfTypes ls, tyCoVarsOfTypes rs)
| pred <- preds
, (ls, rs) <- determined pred ]
, pred' <- pred : transSuperClasses pred
-- Look for fundeps in superclasses too
, (ls, rs) <- determined pred' ]
determined :: PredType -> [([Type],[Type])]
determined pred
= case classifyPredType pred of
EqPred NomEq t1 t2 -> [([t1],[t2]), ([t2],[t1])]
ClassPred cls tys -> local_fds ++ concatMap determined superclasses
where
local_fds = [ instFD fd cls_tvs tys
| fd <- cls_fds ]
(cls_tvs, cls_fds) = classTvsFds cls
superclasses = immSuperClasses cls tys
ClassPred cls tys -> [ instFD fd cls_tvs tys
| let (cls_tvs, cls_fds) = classTvsFds cls
, fd <- cls_fds ]
_ -> []
{-
......
......@@ -1720,8 +1720,8 @@ mkMinimalBySCs ptys = go preds_with_scs []
in_cloud p ps = or [ p `eqType` p' | (_, scs) <- ps, p' <- scs ]
transSuperClasses :: PredType -> [PredType]
-- (transSuperClasses p) returns (p's superclasses)
-- not including p
-- (transSuperClasses p) returns (p's superclasses) not including p
-- Stop if you encounter the same class again
-- See Note [Expanding superclasses]
transSuperClasses p
= go emptyNameSet p
......
{-# language KindSignatures, PolyKinds, TypeFamilies,
NoImplicitPrelude, FlexibleContexts,
MultiParamTypeClasses, GADTs,
ConstraintKinds, FlexibleInstances,
ConstraintKinds, FlexibleInstances, UndecidableInstances,
FunctionalDependencies, UndecidableSuperClasses #-}
module T11480a where
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment