[project @ 2003-12-17 11:43:13 by simonpj]
[ghc-hetmet.git] / ghc / compiler / iface / TcIface.lhs
index 8c45b69..39eadfb 100644 (file)
@@ -529,8 +529,9 @@ selectInsts pool@(Pool insts n_in n_out) cls tycons
 
        -- Reverses the gated decls, but that doesn't matter
     choose2 (gis, decls) (gates, decl)
-       | any (`elem` tycons) gates = (gis,                decl:decls)
-       | otherwise                 = ((gates,decl) : gis, decls)
+       |  null gates   -- Happens when we have 'instance T a where ...'
+        || any (`elem` tycons) gates = (gis,              decl:decls)
+       | otherwise                  = ((gates,decl) : gis, decls)
 \end{code}
 
 %************************************************************************
@@ -586,7 +587,7 @@ selectRules (Pool rules n_in n_out) type_env
        | null gates' = (pool, rule:if_rules)
        | otherwise   = ((gates',rule) : pool, if_rules)
        where
-         gates' = filter (`elemNameEnv` type_env) gates
+         gates' = filter (not . (`elemNameEnv` type_env)) gates
 
 
 tcIfaceRule :: IfaceRule -> IfL IdCoreRule