Skip to content
Snippets Groups Projects
Commit a83c810d authored by Simon Peyton Jones's avatar Simon Peyton Jones Committed by Marge Bot
Browse files

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
parent 765fab98
No related branches found
No related tags found
No related merge requests found
Showing
with 227 additions and 80 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment