X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Ftypecheck%2FInst.lhs;h=a11efe05919dc26dfe1f66edf931f1b703028083;hb=3ee928b370511b9889a581e3e34ebe7ea9376004;hp=b0fe5f95cb8116df90697e653ea26a6c69962637;hpb=0aa1d46a1e5c19553c410dc6ff65b29594a2499f;p=ghc-hetmet.git diff --git a/compiler/typecheck/Inst.lhs b/compiler/typecheck/Inst.lhs index b0fe5f9..a11efe0 100644 --- a/compiler/typecheck/Inst.lhs +++ b/compiler/typecheck/Inst.lhs @@ -161,12 +161,14 @@ ipNamesOfInst other = [] tyVarsOfInst :: Inst -> TcTyVarSet tyVarsOfInst (LitInst {tci_ty = ty}) = tyVarsOfType ty tyVarsOfInst (Dict {tci_pred = pred}) = tyVarsOfPred pred -tyVarsOfInst (Method {tci_oid = id, tci_tys = tys}) = tyVarsOfTypes tys `unionVarSet` idFreeTyVars id +tyVarsOfInst (Method {tci_oid = id, tci_tys = tys}) = tyVarsOfTypes tys `unionVarSet` varTypeTyVars id -- The id might have free type variables; in the case of -- locally-overloaded class methods, for example tyVarsOfInst (ImplicInst {tci_tyvars = tvs, tci_given = givens, tci_wanted = wanteds}) - = (tyVarsOfInsts givens `unionVarSet` tyVarsOfInsts wanteds) `minusVarSet` mkVarSet tvs - + = (tyVarsOfInsts givens `unionVarSet` tyVarsOfInsts wanteds) + `minusVarSet` mkVarSet tvs + `unionVarSet` unionVarSets (map varTypeTyVars tvs) + -- Remember the free tyvars of a coercion tyVarsOfInsts insts = foldr (unionVarSet . tyVarsOfInst) emptyVarSet insts tyVarsOfLIE lie = tyVarsOfInsts (lieToList lie) @@ -333,11 +335,10 @@ mkPredName uniq loc pred_ty IParam ip _ -> getOccName (ipNameName ip) EqPred ty _ -> mkEqPredCoOcc baseOcc where - -- we use the outermost tycon of the lhs, which must be a type - -- function, as the base name for an equality + -- we use the outermost tycon of the lhs, if there is one, to + -- improve readability of Core code baseOcc = case splitTyConApp_maybe ty of - Nothing -> - pprPanic "Inst.mkPredName:" (ppr ty) + Nothing -> mkOccName tcName "$" Just (tc, _) -> getOccName tc \end{code} @@ -752,7 +753,7 @@ lookupSimpleInst (Dict {tci_pred = pred, tci_loc = loc}) (theta, _) = tcSplitPhiTy dfun_rho src_loc = instLocSpan loc dfun = HsVar dfun_id - tys = map (substTyVar tenv') tyvars + tys = substTyVars tenv' tyvars ; if null theta then returnM (GenInst [] (L src_loc $ HsWrap (mkWpTyApps tys) dfun)) else do