diff options
author | Simon Peyton Jones <simon.peytonjones@gmail.com> | 2023-01-12 22:21:40 +0000 |
---|---|---|
committer | Simon Peyton Jones <simon.peytonjones@gmail.com> | 2023-01-31 08:54:52 +0000 |
commit | ae22d1096df1bd83b5ce9ef5d8c2bd8c00e20bad (patch) | |
tree | dc345c52cefcb688e3be7447551cb0a0bedfb492 /compiler/GHC/Tc | |
parent | b69461a06166d2b1c600df87b87656d09122fb7c (diff) | |
download | haskell-wip/T22745.tar.gz |
Improve exprOkForSpeculation for classopswip/T22745
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')
-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) |