import Class ( GenClass, GenClassOp,
isCcallishClass, classBigSig,
classOps, classOpLocalType,
- classOpTagByString
+ classOpTagByString_maybe
)
import Id ( GenId, idType, isDefaultMethodId_maybe )
import ListSetOps ( minusList )
splitSigmaTy, splitAppTy, isTyVarTy, matchTy, mkSigmaTy,
getTyCon_maybe, maybeBoxedPrimType, splitRhoTy, eqTy
)
-import TyVar ( GenTyVar, GenTyVarSet(..), mkTyVarSet, unionTyVarSets )
+import TyVar ( GenTyVar, SYN_IE(GenTyVarSet), mkTyVarSet, unionTyVarSets )
import TysWiredIn ( stringTy )
import Unique ( Unique )
import Util ( zipEqual, panic )
-- Make a method id for the method
let
- tag = classOpTagByString clas occ
- method_id = method_ids !! (tag-1)
- method_ty = tcIdType method_id
+ maybe_tag = classOpTagByString_maybe clas occ
+ (Just tag) = maybe_tag
+ method_id = method_ids !! (tag-1)
+ method_ty = tcIdType method_id
in
+ -- check that the method mentioned is actually in the class:
+ checkMaybeTc maybe_tag (instMethodNotInClassErr occ clas) `thenTc_`
tcInstTcType method_ty `thenNF_Tc` \ (method_tyvars, method_rho) ->
let
ppr sty clas_op, ppStr "in instance",
ppPStr clas_name, pprParendGenType sty inst_ty]
+instMethodNotInClassErr occ clas sty
+ = ppHang (ppStr "Instance mentions a method not in the class")
+ 4 (ppBesides [ppStr "class `", ppr sty clas, ppStr "' method `",
+ ppPStr occ, ppStr "'"])
patMonoBindsCtxt pbind sty
= ppHang (ppStr "In a pattern binding:")