diff options
author | Simon Peyton Jones <simon.peytonjones@gmail.com> | 2023-01-12 22:21:40 +0000 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2023-01-31 13:08:38 -0500 |
commit | a83c810d26aab5944aa8d4821e00bd3938557f2e (patch) | |
tree | d7c93cfa2cbf3443c146b8c0100639d29bf96ca3 /compiler/GHC/Tc/Gen | |
parent | 765fab98b0795bbe8ad50796c55b9408a2af54cf (diff) | |
download | haskell-a83c810d26aab5944aa8d4821e00bd3938557f2e.tar.gz |
Improve exprOkForSpeculation for classops
This patch fixes #22745 and #15205, which are about GHC's
failure to discard unnecessary superclass selections that
yield coercions. See
GHC.Core.Utils Note [exprOkForSpeculation and type classes]
The main changes are:
* Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and
refer to it
* Define new function isTerminatingType, to identify those
guaranteed-terminating dictionary types.
* exprOkForSpeculation has a new (very simple) case for ClassOpId
* ClassOpId has a new field that says if the return type is
an unlifted type, or a terminating type.
This was surprisingly tricky to get right. In particular note
that unlifted types are not terminating types; you can write an
expression of unlifted type, that diverges. Not so for dictionaries
(or, more precisely, for the dictionaries that GHC constructs).
Metric Decrease:
LargeRecord
Diffstat (limited to 'compiler/GHC/Tc/Gen')
-rw-r--r-- | compiler/GHC/Tc/Gen/Splice.hs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/GHC/Tc/Gen/Splice.hs b/compiler/GHC/Tc/Gen/Splice.hs index e1a91ad495..c12ab7a1aa 100644 --- a/compiler/GHC/Tc/Gen/Splice.hs +++ b/compiler/GHC/Tc/Gen/Splice.hs @@ -2057,7 +2057,7 @@ reifyThing (AGlobal (AnId id)) = do { ty <- reifyType (idType id) ; let v = reifyName id ; case idDetails id of - ClassOpId cls -> return (TH.ClassOpI v ty (reifyName cls)) + ClassOpId cls _ -> return (TH.ClassOpI v ty (reifyName cls)) RecSelId{sel_tycon=RecSelData tc} -> return (TH.VarI (reifySelector id tc) ty Nothing) _ -> return (TH.VarI v ty Nothing) |