diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-10-15 11:08:26 -0400 |
---|---|---|
committer | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-10-16 09:58:05 -0400 |
commit | a1b6eb15535e2244146b01fd69faef629e30e38a (patch) | |
tree | a19ae5be341be2c0eba0113d3ba8fc0d1f34d505 /compiler/iface/BuildTyCl.hs | |
parent | 426b0ddc79890f80a8ceeef135371533f066b9ba (diff) | |
download | haskell-wip/T17360.tar.gz |
Make isTcLevPoly more conservative with newtypes (#17360)wip/T17360
`isTcLevPoly` gives an approximate answer for when a type constructor
is levity polymorphic when fully applied, where `True` means
"possibly levity polymorphic" and `False` means "definitely not
levity polymorphic". `isTcLevPoly` returned `False` for newtypes,
which is incorrect in the presence of `UnliftedNewtypes`, leading
to #17360. This patch tweaks `isTcLevPoly` to return `True` for
newtypes instead.
Fixes #17360.
Diffstat (limited to 'compiler/iface/BuildTyCl.hs')
-rw-r--r-- | compiler/iface/BuildTyCl.hs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/iface/BuildTyCl.hs b/compiler/iface/BuildTyCl.hs index dc1c843889..827b89983f 100644 --- a/compiler/iface/BuildTyCl.hs +++ b/compiler/iface/BuildTyCl.hs @@ -54,12 +54,14 @@ mkNewTyConRhs tycon_name tycon con ; return (NewTyCon { data_con = con, nt_rhs = rhs_ty, nt_etad_rhs = (etad_tvs, etad_rhs), - nt_co = nt_ax } ) } + nt_co = nt_ax, + nt_lev_poly = isKindLevPoly res_kind } ) } -- Coreview looks through newtypes with a Nothing -- for nt_co, or uses explicit coercions otherwise where - tvs = tyConTyVars tycon - roles = tyConRoles tycon + tvs = tyConTyVars tycon + roles = tyConRoles tycon + res_kind = tyConResKind tycon con_arg_ty = case dataConRepArgTys con of [arg_ty] -> arg_ty tys -> pprPanic "mkNewTyConRhs" (ppr con <+> ppr tys) |