Skip to content

Commit

Permalink
Emit addUsedRdrNames for the datacons in a standalone deriving (Trac …
Browse files Browse the repository at this point in the history
…#7969)
  • Loading branch information
Simon Peyton Jones committed Jun 17, 2013
1 parent 4c01e10 commit b2cde43
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions compiler/typecheck/TcDeriv.lhs
Expand Up @@ -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))
Expand Down

0 comments on commit b2cde43

Please sign in to comment.