Instantiate GND bindings with an explicit type signature
Summary: Before, we were using visible type application to apply impredicative types to `coerce` in `GeneralizedNewtypeDeriving`-generated bindings. This approach breaks down when combined with `QuantifiedConstraints` in certain ways, which #14883 and #15290 provide examples of. See Note [GND and QuantifiedConstraints] for all the gory details. To avoid this issue, we instead use an explicit type signature to instantiate each GND binding, and use that to bind any type variables that might be bound by a class method's type signature. This reduces the need to impredicative type applications, and more importantly, makes the programs from #14883 and #15290 work again. Test Plan: make test TEST="T15290b T15290c T15290d T14883" Reviewers: simonpj, bgamari Reviewed By: simonpj Subscribers: rwbarton, thomie, carter GHC Trac Issues: #14883, #15290 Differential Revision: https://phabricator.haskell.org/D4895
Showing
- compiler/hsSyn/HsUtils.hs 1 addition, 1 deletioncompiler/hsSyn/HsUtils.hs
- compiler/rename/RnSource.hs 1 addition, 1 deletioncompiler/rename/RnSource.hs
- compiler/typecheck/TcGenDeriv.hs 126 additions, 22 deletionscompiler/typecheck/TcGenDeriv.hs
- testsuite/tests/deriving/should_compile/T14578.stderr 48 additions, 55 deletionstestsuite/tests/deriving/should_compile/T14578.stderr
- testsuite/tests/deriving/should_compile/T14883.hs 30 additions, 0 deletionstestsuite/tests/deriving/should_compile/T14883.hs
- testsuite/tests/deriving/should_compile/T15290c.hs 20 additions, 0 deletionstestsuite/tests/deriving/should_compile/T15290c.hs
- testsuite/tests/deriving/should_compile/T15290d.hs 12 additions, 0 deletionstestsuite/tests/deriving/should_compile/T15290d.hs
- testsuite/tests/deriving/should_compile/all.T 3 additions, 0 deletionstestsuite/tests/deriving/should_compile/all.T
- testsuite/tests/deriving/should_fail/T15073.stderr 16 additions, 10 deletionstestsuite/tests/deriving/should_fail/T15073.stderr
- testsuite/tests/deriving/should_fail/T4846.stderr 3 additions, 2 deletionstestsuite/tests/deriving/should_fail/T4846.stderr
Loading
Please register or sign in to comment