Don't import FastString in HsVersions.h
[ghc-hetmet.git] / compiler / typecheck / TcTyClsDecls.lhs
index f3abbe9..12fb28d 100644 (file)
@@ -51,6 +51,7 @@ import SrcLoc
 import ListSetOps
 import Digraph
 import DynFlags
+import FastString
 
 import Data.List
 import Control.Monad    ( mplus )
@@ -724,15 +725,17 @@ tcTyClDecl1 calc_isrec
        -- Check that the stupid theta is empty for a GADT-style declaration
   ; checkTc (null stupid_theta || h98_syntax) (badStupidTheta tc_name)
 
+       -- Check that a newtype has exactly one constructor
+       -- Do this before checking for empty data decls, so that
+       -- we don't suggest -XEmptyDataDecls for newtypes
+  ; checkTc (new_or_data == DataType || isSingleton cons) 
+           (newtypeConError tc_name (length cons))
+
        -- Check that there's at least one condecl,
        -- or else we're reading an hs-boot file, or -XEmptyDataDecls
   ; checkTc (not (null cons) || empty_data_decls || is_boot)
            (emptyConDeclsErr tc_name)
     
-       -- Check that a newtype has exactly one constructor
-  ; checkTc (new_or_data == DataType || isSingleton cons) 
-           (newtypeConError tc_name (length cons))
-
   ; tycon <- fixM (\ tycon -> do 
        { data_cons <- mapM (addLocM (tcConDecl unbox_strict ex_ok tycon final_tvs))
                             cons
@@ -774,7 +777,8 @@ tcTyClDecl1 calc_isrec
                    tycon_name = tyConName (classTyCon clas)
                    tc_isrec = calc_isrec tycon_name
                in
-               buildClass class_name tvs' ctxt' fds' ats'
+               buildClass False {- Must include unfoldings for selectors -}
+                          class_name tvs' ctxt' fds' ats'
                           sig_stuff tc_isrec)
   ; return (AClass clas : ats')
       -- NB: Order is important due to the call to `mkGlobalThings' when