Synchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862)

Authored by RyanGlScott on Jun 14 2019, 10:07 AM.

Description

Synchronize ClsInst.doTyConApp with TcTypeable validity checks (Trac #15862)

Issue Trac #15862 demonstrated examples of type constructors on which
TcTypeable.tyConIsTypeable would return False, but the Typeable
constraint solver in ClsInst (in particular, doTyConApp) would
try to generate Typeable evidence for anyway, resulting in
disaster. This incongruity was caused by the fact that doTyConApp
was using a weaker validity check than tyConIsTypeable to determine
if a type constructor warrants Typeable evidence or not. The
solution, perhaps unsurprisingly, is to use tyConIsTypeable in
doTyConApp instead.

To avoid import cycles between ClsInst and TcTypeable, I factored
out tyConIsTypeable into its own module, TcTypeableValidity.

Fixes Trac #15862.

(cherry picked from commit 25ee60cdae6ddedaf6b4677c6327c0f31c81073a)

Details

Committed
bgamariJun 24 2019, 5:35 PM
Parents
rGHCbe72b2724fd0: SafeHaskell: Don't throw -Wsafe warning if module is declared Safe
Branches
Unknown
Tags
Unknown