[commit: ghc] ghc-7.10: Make AutoDeriveTypeable work for associated datatypes (fix #9999) (5541b6c)
git at git.haskell.org
git at git.haskell.org
Mon Jan 19 14:01:58 UTC 2015
Repository : ssh://git@git.haskell.org/ghc
On branch : ghc-7.10
Link : http://ghc.haskell.org/trac/ghc/changeset/5541b6c34161278180c45d378941d53ed20d9a5a/ghc
>---------------------------------------------------------------
commit 5541b6c34161278180c45d378941d53ed20d9a5a
Author: Jose Pedro Magalhaes <dreixel at gmail.com>
Date: Mon Jan 19 13:36:03 2015 +0000
Make AutoDeriveTypeable work for associated datatypes (fix #9999)
(cherry picked from commit d839493991e508160d416311ba47b7a7e2d62aae)
>---------------------------------------------------------------
5541b6c34161278180c45d378941d53ed20d9a5a
compiler/typecheck/TcDeriv.hs | 13 +++++++++----
testsuite/tests/typecheck/should_compile/T9999.hs | 13 +++++++++++++
testsuite/tests/typecheck/should_compile/all.T | 1 +
3 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/compiler/typecheck/TcDeriv.hs b/compiler/typecheck/TcDeriv.hs
index 8b7af86..c5f3c25 100644
--- a/compiler/typecheck/TcDeriv.hs
+++ b/compiler/typecheck/TcDeriv.hs
@@ -561,11 +561,16 @@ deriveAutoTypeable auto_typeable done_specs tycl_decls
do_one cls (L _ decl)
= do { tc <- tcLookupTyCon (tcdName decl)
- ; if (isTypeSynonymTyCon tc || isTypeFamilyTyCon tc
+ -- Traverse into class declarations to check if they have ATs (#9999)
+ ; ats <- if isClassDecl decl
+ then concatMapM (do_one cls) (map (fmap FamDecl) (tcdATs decl))
+ else return []
+ ; rest <- if (isTypeSynonymTyCon tc || isTypeFamilyTyCon tc
|| tyConName tc `elemNameSet` done_tcs)
- -- Do not derive Typeable for type synonyms or type families
- then return []
- else mkPolyKindedTypeableEqn cls tc }
+ -- Do not derive Typeable for type synonyms or type families
+ then return []
+ else mkPolyKindedTypeableEqn cls tc
+ ; return (ats ++ rest) }
------------------------------------------------------------------
deriveTyDecl :: LTyClDecl Name -> TcM [EarlyDerivSpec]
diff --git a/testsuite/tests/typecheck/should_compile/T9999.hs b/testsuite/tests/typecheck/should_compile/T9999.hs
new file mode 100644
index 0000000..656e913
--- /dev/null
+++ b/testsuite/tests/typecheck/should_compile/T9999.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE AutoDeriveTypeable, PolyKinds, TypeFamilies, StandaloneDeriving #-}
+
+module T9999 where
+
+import Data.Typeable
+
+data family F a
+
+class C a where
+ data F1 a
+ type F2 a
+
+main = typeRep (Proxy :: Proxy F) == typeRep (Proxy :: Proxy F1)
diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T
index 9d915eb..df07a3e 100644
--- a/testsuite/tests/typecheck/should_compile/all.T
+++ b/testsuite/tests/typecheck/should_compile/all.T
@@ -438,3 +438,4 @@ test('T7643', normal, compile, [''])
test('T9834', normal, compile, [''])
test('T9892', normal, compile, [''])
test('T9971', normal, compile, [''])
+test('T9999', normal, compile, [''])
More information about the ghc-commits
mailing list