diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2020-04-05 12:10:10 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-04-08 16:43:44 -0400 |
commit | 7802fa17a9a1a0f02fbf95170c13d7a9711a681e (patch) | |
tree | 6d43a4767833369ac59b1de7cf2841d074aea78a /compiler/GHC | |
parent | 04b6cf947ea065a210a216cc91f918cc1660d430 (diff) | |
download | haskell-7802fa17a9a1a0f02fbf95170c13d7a9711a681e.tar.gz |
Handle promoted data constructors in typeToLHsType correctly
Instead of using `nlHsTyVar`, which hardcodes `NotPromoted`, have
`typeToLHsType` pick between `Promoted` and `NotPromoted` by checking
if a type constructor is promoted using `isPromotedDataCon`.
Fixes #18020.
Diffstat (limited to 'compiler/GHC')
-rw-r--r-- | compiler/GHC/Hs/Utils.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/GHC/Hs/Utils.hs b/compiler/GHC/Hs/Utils.hs index 99a5de9365..75d9219cbf 100644 --- a/compiler/GHC/Hs/Utils.hs +++ b/compiler/GHC/Hs/Utils.hs @@ -113,6 +113,7 @@ import GHC.Tc.Types.Evidence import GHC.Types.Name.Reader import GHC.Types.Var import GHC.Core.TyCo.Rep +import GHC.Core.TyCon import GHC.Core.Type ( appTyArgFlags, splitAppTys, tyConArgFlags, tyConAppNeedsKindSig ) import TysWiredIn ( unitTy ) import GHC.Tc.Utils.TcType @@ -686,7 +687,11 @@ typeToLHsType ty | otherwise = ty' where ty' :: LHsType GhcPs - ty' = go_app (nlHsTyVar (getRdrName tc)) args (tyConArgFlags tc args) + ty' = go_app (noLoc $ HsTyVar noExtField prom $ noLoc $ getRdrName tc) + args (tyConArgFlags tc args) + + prom :: PromotionFlag + prom = if isPromotedDataCon tc then IsPromoted else NotPromoted go ty@(AppTy {}) = go_app (go head) args (appTyArgFlags head args) where head :: Type |