summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2013-06-17 22:45:28 +0100
committerSimon Peyton Jones <simonpj@microsoft.com>2013-06-17 22:45:28 +0100
commitb2cde434bbf3060dc5eda39876e4c9180aea1d1a (patch)
tree199281b0f47f85e06d967c2593ab9b678eb2c347 /compiler
parent4c01e105a75776b31a4507102d00856d9239390e (diff)
downloadhaskell-b2cde434bbf3060dc5eda39876e4c9180aea1d1a.tar.gz
Emit addUsedRdrNames for the datacons in a standalone deriving (Trac #7969)
Diffstat (limited to 'compiler')
-rw-r--r--compiler/typecheck/TcDeriv.lhs18
1 files changed, 15 insertions, 3 deletions
diff --git a/compiler/typecheck/TcDeriv.lhs b/compiler/typecheck/TcDeriv.lhs
index fb3e7ee300..e9f6d28ff3 100644
--- a/compiler/typecheck/TcDeriv.lhs
+++ b/compiler/typecheck/TcDeriv.lhs
@@ -704,10 +704,22 @@ mkEqnHelp orig tvs cls cls_tys tc_app mtheta
-- For standalone deriving (mtheta /= Nothing),
-- check that all the data constructors are in scope.
; rdr_env <- getGlobalRdrEnv
- ; let hidden_data_cons = not (isWiredInName (tyConName rep_tc)) &&
+ ; let data_con_names = map dataConName (tyConDataCons rep_tc)
+ hidden_data_cons = not (isWiredInName (tyConName rep_tc)) &&
(isAbstractTyCon rep_tc ||
- any not_in_scope (tyConDataCons rep_tc))
- not_in_scope dc = null (lookupGRE_Name rdr_env (dataConName dc))
+ any not_in_scope data_con_names)
+ not_in_scope dc = null (lookupGRE_Name rdr_env dc)
+
+ -- Make a Qual RdrName that will do for each DataCon
+ -- so we can report it as used (Trac #7969)
+ data_con_rdrs = [ mkRdrQual (is_as (is_decl imp_spec)) occ
+ | dc_name <- data_con_names
+ , let occ = nameOccName dc_name
+ gres = lookupGRE_Name rdr_env dc_name
+ , not (null gres)
+ , Imported (imp_spec:_) <- [gre_prov (head gres)] ]
+
+ ; addUsedRdrNames data_con_rdrs
; unless (isNothing mtheta || not hidden_data_cons)
(bale_out (derivingHiddenErr tycon))