Commit 9f157b36 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Make sure to check class name when filtering instances

parent 0c87254e
...@@ -313,7 +313,7 @@ evalDeclarations decl = do ...@@ -313,7 +313,7 @@ evalDeclarations decl = do
cleanUpDuplicateInstances :: GhcMonad m => m () cleanUpDuplicateInstances :: GhcMonad m => m ()
cleanUpDuplicateInstances = modifySession $ \hscEnv -> cleanUpDuplicateInstances = modifySession $ \hscEnv ->
let let
-- Get all class instancesj -- Get all class instances
ic = hsc_IC hscEnv ic = hsc_IC hscEnv
(clsInsts, famInsts) = ic_instances ic (clsInsts, famInsts) = ic_instances ic
-- Remove duplicates -- Remove duplicates
...@@ -321,11 +321,11 @@ cleanUpDuplicateInstances = modifySession $ \hscEnv -> ...@@ -321,11 +321,11 @@ cleanUpDuplicateInstances = modifySession $ \hscEnv ->
in hscEnv { hsc_IC = ic { ic_instances = (clsInsts', famInsts) } } in hscEnv { hsc_IC = ic { ic_instances = (clsInsts', famInsts) } }
where where
instEq :: ClsInst -> ClsInst -> Bool instEq :: ClsInst -> ClsInst -> Bool
instEq ClsInst{is_tvs = tpl_tvs,is_tys = tpl_tys} ClsInst{is_tys = tpl_tys'} = instEq ClsInst{is_tvs = tpl_tvs,is_tys = tpl_tys, is_cls = cls} ClsInst{is_tys = tpl_tys', is_cls = cls'} =
#if MIN_VERSION_ghc(7,8,0) #if MIN_VERSION_ghc(7,8,0)
-- Only support replacing instances on GHC 7.8 and up -- Only support replacing instances on GHC 7.8 and up
let tpl_tv_set = mkVarSet tpl_tvs let tpl_tv_set = mkVarSet tpl_tvs
in isJust $ tcMatchTys tpl_tv_set tpl_tys tpl_tys' in cls == cls' && isJust (tcMatchTys tpl_tv_set tpl_tys tpl_tys')
#else #else
False False
#endif #endif
......
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