summaryrefslogtreecommitdiff
path: root/compiler/backpack
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2017-02-27 23:48:30 -0800
committerEdward Z. Yang <ezyang@cs.stanford.edu>2017-03-02 15:59:02 -0800
commitfb5cd9d6d6185afe6d4ef2f3df3f895b6d0abf4c (patch)
treeba77538afca8be56c6c4ea77e6f7afda817df418 /compiler/backpack
parente71068617d15b0fea65fe24e20c0ab0db9fc660f (diff)
downloadhaskell-fb5cd9d6d6185afe6d4ef2f3df3f895b6d0abf4c.tar.gz
Properly represent abstract classes in Class and IfaceDecl
Summary: Previously, abstract classes looked very much like normal classes, except that they happened to have no methods, superclasses or ATs, and they came from boot files. This patch gives abstract classes a proper representation in Class and IfaceDecl, by moving the things which are never defined for abstract classes into ClassBody/IfaceClassBody. Because Class is abstract, this change had ~no disruption to any of the code in GHC; if you ask about the methods of an abstract class, we'll just give you an empty list. This also fixes a bug where abstract type classes were incorrectly treated as representationally injective (they're not!) Fixes #13347, and a TODO in the code. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, bgamari, austin Subscribers: goldfire, thomie Differential Revision: https://phabricator.haskell.org/D3236
Diffstat (limited to 'compiler/backpack')
-rw-r--r--compiler/backpack/RnModIface.hs18
1 files changed, 11 insertions, 7 deletions
diff --git a/compiler/backpack/RnModIface.hs b/compiler/backpack/RnModIface.hs
index 7696d5f075..2e738c1ec6 100644
--- a/compiler/backpack/RnModIface.hs
+++ b/compiler/backpack/RnModIface.hs
@@ -451,15 +451,11 @@ rnIfaceDecl d@IfaceFamily{} = do
}
rnIfaceDecl d@IfaceClass{} = do
name <- rnIfaceGlobal (ifName d)
- ctxt <- mapM rnIfaceType (ifCtxt d)
binders <- mapM rnIfaceTyConBinder (ifBinders d)
- ats <- mapM rnIfaceAT (ifATs d)
- sigs <- mapM rnIfaceClassOp (ifSigs d)
- return d { ifName = name
- , ifCtxt = ctxt
+ body <- rnIfaceClassBody (ifBody d)
+ return d { ifName = name
, ifBinders = binders
- , ifATs = ats
- , ifSigs = sigs
+ , ifBody = body
}
rnIfaceDecl d@IfaceAxiom{} = do
name <- rnIfaceNeverExported (ifName d)
@@ -491,6 +487,14 @@ rnIfaceDecl d@IfacePatSyn{} = do
, ifPatTy = pat_ty
}
+rnIfaceClassBody :: Rename IfaceClassBody
+rnIfaceClassBody IfAbstractClass = return IfAbstractClass
+rnIfaceClassBody d@IfConcreteClass{} = do
+ ctxt <- mapM rnIfaceType (ifClassCtxt d)
+ ats <- mapM rnIfaceAT (ifATs d)
+ sigs <- mapM rnIfaceClassOp (ifSigs d)
+ return d { ifClassCtxt = ctxt, ifATs = ats, ifSigs = sigs }
+
rnIfaceFamTyConFlav :: Rename IfaceFamTyConFlav
rnIfaceFamTyConFlav (IfaceClosedSynFamilyTyCon (Just (n, axs)))
= IfaceClosedSynFamilyTyCon . Just <$> ((,) <$> rnIfaceNeverExported n