\begin{code}
recordSelectorFieldLabel :: Id -> (TyCon, FieldLabel)
-recordSelectorFieldLabel id = case globalIdDetails id of
- RecordSelId tycon lbl _ -> (tycon,lbl)
- other -> panic "recordSelectorFieldLabel"
+recordSelectorFieldLabel id
+ = case globalIdDetails id of
+ RecordSelId { sel_tycon = tycon, sel_label = lbl } -> (tycon,lbl)
+ other -> panic "recordSelectorFieldLabel"
isRecordSelector id = case globalIdDetails id of
RecordSelId {} -> True
= VanillaGlobal -- Imported from elsewhere, a default method Id.
| RecordSelId -- The Id for a record selector
- { sel_tycon :: TyCon
+ { sel_tycon :: TyCon -- For a data type family, this is the *instance* TyCon
+ -- not the family TyCon
, sel_label :: FieldLabel
, sel_naughty :: Bool -- True <=> naughty
} -- See Note [Naughty record selectors]
| otherwise = sel_id
where
is_naughty = not (tyVarsOfType field_ty `subVarSet` data_tv_set)
- sel_id_details = RecordSelId tycon field_label is_naughty
+ sel_id_details = RecordSelId { sel_tycon = tycon, sel_label = field_label, sel_naughty = is_naughty }
+ -- For a data type family, the tycon is the *instance* TyCon
-- Escapist case here for naughty constructors
-- We give it no IdInfo, and a type of forall a.a (never looked at)