summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorsimonpj@microsoft.com <unknown>2010-12-14 17:47:55 +0000
committersimonpj@microsoft.com <unknown>2010-12-14 17:47:55 +0000
commit4d8c7c976104d2e39a1183967ec0f254a0fc0a47 (patch)
tree48007aa4f9ebcef52a06c6bef6aa0e0e2db2dfbd /compiler
parent492303f32eb179c14a095aa175541bdbff486179 (diff)
downloadhaskell-4d8c7c976104d2e39a1183967ec0f254a0fc0a47.tar.gz
Fix Trac #4841: behave right with TypeSynonymInstances and NoFlexibleInstances
When we have TypeSynonymInstances without FlexibleInstances we should still insist on a H98-style instance head, after looking through the synonym. This patch also make FlexibleInstances imply TypeSynonymInstances. Anything else is a bit awkward, and not very useful.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/main/DynFlags.hs1
-rw-r--r--compiler/typecheck/TcType.lhs3
2 files changed, 4 insertions, 0 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index e3de00655f..8f6f45dc75 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -1658,6 +1658,7 @@ impliedFlags
, (Opt_LiberalTypeSynonyms, turnOn, Opt_ExplicitForAll)
, (Opt_ExistentialQuantification, turnOn, Opt_ExplicitForAll)
, (Opt_PolymorphicComponents, turnOn, Opt_ExplicitForAll)
+ , (Opt_FlexibleInstances, turnOn, Opt_TypeSynonymInstances)
, (Opt_RebindableSyntax, turnOff, Opt_ImplicitPrelude) -- NB: turn off!
diff --git a/compiler/typecheck/TcType.lhs b/compiler/typecheck/TcType.lhs
index 89aba6504f..50ac35ab50 100644
--- a/compiler/typecheck/TcType.lhs
+++ b/compiler/typecheck/TcType.lhs
@@ -956,6 +956,9 @@ tcInstHeadTyAppAllTyVars :: Type -> Bool
-- Used in Haskell-98 mode, for the argument types of an instance head
-- These must be a constructor applied to type variable arguments
tcInstHeadTyAppAllTyVars ty
+ | Just ty' <- tcView ty -- Look through synonyms
+ = tcInstHeadTyAppAllTyVars ty'
+ | otherwise
= case ty of
TyConApp _ tys -> ok tys
FunTy arg res -> ok [arg, res]