Skip to content

Improve exprOkForSpeculation for classops

Simon Peyton Jones requested to merge wip/T22745 into master

This patch fixes #22745 (closed) and #15205 (closed), 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:

  • exprOkForSpeculation has a new (very simple) case for ClassOpId

  • ClassOpId has a field that says if the return type is a "terminating type"; i.e. unlifted or non-newtype dictionary type.

  • Define GHC.Type.isTerminatingType to identify these types.

  • Write new Note [NON-BOTTOM_DICTS invariant] in GHC.Core, and refer to it

Merge request reports