diff --git a/compiler/basicTypes/DataCon.lhs b/compiler/basicTypes/DataCon.lhs index c82f018962cbbd818b0b999817b65a234f396ab7..edb3627993d28c2732c7085f1e16f00d7400868b 100644 --- a/compiler/basicTypes/DataCon.lhs +++ b/compiler/basicTypes/DataCon.lhs @@ -391,6 +391,7 @@ data DataCon -- The actual fixity is stored elsewhere dcPromoted :: Maybe TyCon -- The promoted TyCon if this DataCon is promotable + -- See Note [Promoted data constructors] in TyCon } deriving Data.Typeable.Typeable @@ -559,9 +560,10 @@ mkDataCon name declared_infix mkFunTys rep_arg_tys $ mkTyConApp rep_tycon (mkTyVarTys univ_tvs) - mb_promoted - | is_vanilla -- No existentials or context - , all (isLiftedTypeKind . tyVarKind) univ_tvs + mb_promoted -- See Note [Promoted data constructors] in TyCon + | all (isLiftedTypeKind . tyVarKind) (univ_tvs ++ ex_tvs) + -- No kind polymorphism, and all of kind * + , null full_theta -- No constraints , all isPromotableType orig_arg_tys = Just (mkPromotedDataCon con name (getUnique name) prom_kind arity) | otherwise diff --git a/compiler/types/TyCon.lhs b/compiler/types/TyCon.lhs index 5398adc8f1fdea0f519089527926b539b4e682a5..e90cdec24bda743b3821ab32f011d99e79b7f766 100644 --- a/compiler/types/TyCon.lhs +++ b/compiler/types/TyCon.lhs @@ -581,8 +581,10 @@ Note [Promoted data constructors] A data constructor can be promoted to become a type constructor, via the PromotedTyCon alternative in TyCon. -* Only "vanilla" data constructors are promoted; ones with no GADT - stuff, no existentials, etc. We might generalise this later. +* Only data constructors with + (a) no kind polymorphism + (b) no constraints in its type (eg GADTs) + are promoted. Existentials are ok; see Trac #7347. * The TyCon promoted from a DataCon has the *same* Name and Unique as the DataCon. Eg. If the data constructor Data.Maybe.Just(unique 78,