X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Ftypecheck%2FTcInstDcls.lhs;h=d312cee87f1a7954258e8f9c7265c2ce5b814b4c;hb=e83fa2eba7ef2302fae8a6be86a9f495b4144387;hp=cf705ae2beffdaaa3079460665a9af2223592d03;hpb=3194c5289207114a3417be884b2174a4375b808f;p=ghc-hetmet.git diff --git a/ghc/compiler/typecheck/TcInstDcls.lhs b/ghc/compiler/typecheck/TcInstDcls.lhs index cf705ae..d312cee 100644 --- a/ghc/compiler/typecheck/TcInstDcls.lhs +++ b/ghc/compiler/typecheck/TcInstDcls.lhs @@ -629,6 +629,18 @@ tcMethods clas inst_tyvars inst_tyvars' dfun_theta' inst_tys' -- -- Solution: make meth_insts available, so that 'then' refers directly -- to the local 'bind' rather than going via the dictionary. + -- + -- BUT WATCH OUT! If the method type mentions the class variable, then + -- this optimisation is not right. Consider + -- class C a where + -- op :: Eq a => a + -- + -- instance C Int where + -- op = op + -- The occurrence of 'op' on the rhs gives rise to a constraint + -- op at Int + -- The trouble is that the 'meth_inst' for op, which is 'available', also + -- looks like 'op at Int'. But they are not the same. let all_insts = avail_insts ++ catMaybes meth_insts xtve = inst_tyvars `zip` inst_tyvars'