Commit 7802fa17 authored by Ryan Scott's avatar Ryan Scott Committed by Marge Bot

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.
parent 04b6cf94
Pipeline #17817 failed with stages
in 441 minutes and 57 seconds
......@@ -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
......
......@@ -9,7 +9,7 @@ Derived class instances:
GHC.Base.sconcat ::
GHC.Base.NonEmpty (T14578.Wat f g a) -> T14578.Wat f g a
GHC.Base.stimes ::
forall (b :: TYPE GHC.Types.LiftedRep).
forall (b :: TYPE 'GHC.Types.LiftedRep).
GHC.Real.Integral b => b -> T14578.Wat f g a -> T14578.Wat f g a
(GHC.Base.<>)
= GHC.Prim.coerce
......@@ -37,12 +37,12 @@ Derived class instances:
instance GHC.Base.Functor f =>
GHC.Base.Functor (T14578.App f) where
GHC.Base.fmap ::
forall (a :: TYPE GHC.Types.LiftedRep)
(b :: TYPE GHC.Types.LiftedRep).
forall (a :: TYPE 'GHC.Types.LiftedRep)
(b :: TYPE 'GHC.Types.LiftedRep).
(a -> b) -> T14578.App f a -> T14578.App f b
(GHC.Base.<$) ::
forall (a :: TYPE GHC.Types.LiftedRep)
(b :: TYPE GHC.Types.LiftedRep).
forall (a :: TYPE 'GHC.Types.LiftedRep)
(b :: TYPE 'GHC.Types.LiftedRep).
a -> T14578.App f b -> T14578.App f a
GHC.Base.fmap
= GHC.Prim.coerce
......@@ -56,23 +56,23 @@ Derived class instances:
instance GHC.Base.Applicative f =>
GHC.Base.Applicative (T14578.App f) where
GHC.Base.pure ::
forall (a :: TYPE GHC.Types.LiftedRep). a -> T14578.App f a
forall (a :: TYPE 'GHC.Types.LiftedRep). a -> T14578.App f a
(GHC.Base.<*>) ::
forall (a :: TYPE GHC.Types.LiftedRep)
(b :: TYPE GHC.Types.LiftedRep).
forall (a :: TYPE 'GHC.Types.LiftedRep)
(b :: TYPE 'GHC.Types.LiftedRep).
T14578.App f (a -> b) -> T14578.App f a -> T14578.App f b
GHC.Base.liftA2 ::
forall (a :: TYPE GHC.Types.LiftedRep)
(b :: TYPE GHC.Types.LiftedRep)
(c :: TYPE GHC.Types.LiftedRep).
forall (a :: TYPE 'GHC.Types.LiftedRep)
(b :: TYPE 'GHC.Types.LiftedRep)
(c :: TYPE 'GHC.Types.LiftedRep).
(a -> b -> c) -> T14578.App f a -> T14578.App f b -> T14578.App f c
(GHC.Base.*>) ::
forall (a :: TYPE GHC.Types.LiftedRep)
(b :: TYPE GHC.Types.LiftedRep).
forall (a :: TYPE 'GHC.Types.LiftedRep)
(b :: TYPE 'GHC.Types.LiftedRep).
T14578.App f a -> T14578.App f b -> T14578.App f b
(GHC.Base.<*) ::
forall (a :: TYPE GHC.Types.LiftedRep)
(b :: TYPE GHC.Types.LiftedRep).
forall (a :: TYPE 'GHC.Types.LiftedRep)
(b :: TYPE 'GHC.Types.LiftedRep).
T14578.App f a -> T14578.App f b -> T14578.App f a
GHC.Base.pure
= GHC.Prim.coerce
......
......@@ -8,16 +8,16 @@ Derived class instances:
T14579.Glurp a -> T14579.Glurp a -> GHC.Types.Bool
(GHC.Classes.==)
= GHC.Prim.coerce
@(T14579.Wat @a (Data.Proxy.Proxy @a)
-> T14579.Wat @a (Data.Proxy.Proxy @a) -> GHC.Types.Bool)
@(T14579.Wat @a ('Data.Proxy.Proxy @a)
-> T14579.Wat @a ('Data.Proxy.Proxy @a) -> GHC.Types.Bool)
@(T14579.Glurp a -> T14579.Glurp a -> GHC.Types.Bool)
((GHC.Classes.==) @(T14579.Wat @a (Data.Proxy.Proxy @a)))
((GHC.Classes.==) @(T14579.Wat @a ('Data.Proxy.Proxy @a)))
(GHC.Classes./=)
= GHC.Prim.coerce
@(T14579.Wat @a (Data.Proxy.Proxy @a)
-> T14579.Wat @a (Data.Proxy.Proxy @a) -> GHC.Types.Bool)
@(T14579.Wat @a ('Data.Proxy.Proxy @a)
-> T14579.Wat @a ('Data.Proxy.Proxy @a) -> GHC.Types.Bool)
@(T14579.Glurp a -> T14579.Glurp a -> GHC.Types.Bool)
((GHC.Classes./=) @(T14579.Wat @a (Data.Proxy.Proxy @a)))
((GHC.Classes./=) @(T14579.Wat @a ('Data.Proxy.Proxy @a)))
instance forall a (x :: Data.Proxy.Proxy a).
GHC.Classes.Eq a =>
......
......@@ -3,7 +3,7 @@ T15073.hs:8:12: error:
• Illegal unboxed tuple type as function argument: (# Foo a #)
Perhaps you intended to use UnboxedTuples
• In the type signature:
p :: Foo a -> Unit# @GHC.Types.LiftedRep (Foo a)
p :: Foo a -> Unit# @'GHC.Types.LiftedRep (Foo a)
When typechecking the code for ‘p’
in a derived instance for ‘P (Foo a)’:
To see the code I am typechecking, use -ddump-deriv
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment