Synchronize ClsInst.doTyConApp with TcTypeable validity checks (#15862)
Issue #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 #15862. (cherry picked from commit 25ee60cd)
Showing
- compiler/ghc.cabal.in 1 addition, 0 deletionscompiler/ghc.cabal.in
- compiler/typecheck/ClsInst.hs 2 additions, 1 deletioncompiler/typecheck/ClsInst.hs
- compiler/typecheck/TcTypeable.hs 1 addition, 31 deletionscompiler/typecheck/TcTypeable.hs
- compiler/typecheck/TcTypeableValidity.hs 46 additions, 0 deletionscompiler/typecheck/TcTypeableValidity.hs
- testsuite/tests/typecheck/should_fail/T15862.hs 36 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T15862.hs
- testsuite/tests/typecheck/should_fail/T15862.stderr 28 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T15862.stderr
- testsuite/tests/typecheck/should_fail/all.T 1 addition, 0 deletionstestsuite/tests/typecheck/should_fail/all.T
Loading
Please register or sign in to comment