Make typeToLHsType produce kind signatures for tycon applications
authorRyan Scott <ryan.gl.scott@gmail.com>
Thu, 4 Jan 2018 01:11:31 +0000 (20:11 -0500)
committerBen Gamari <ben@smart-cactus.org>
Fri, 12 Jan 2018 20:19:25 +0000 (15:19 -0500)
commitebf8e07629a3adeddd9267579524c28951d83a7e
tree3d04d6b1eecd399c80dc6713a1f2581b2f1d33c9
parente32f582783086595bc3d69a35d19a59707e2831d
Make typeToLHsType produce kind signatures for tycon applications

Summary:
`GeneralizedNewtypeDeriving` generates calls to `coerce`
which take visible type arguments. These types must be produced by
way of `typeToLHsType`, which converts a `Type` to an `LHsType`.
However, `typeToLHsType` was leaving off important kind information
when a `Type` contained a poly-kinded tycon application, leading to
incorrectly generated code in #14579.

This fixes the issue by tweaking `typeToLHsType` to generate
explicit kind signatures for tycon applications. This makes the
generated code noisier, but at least the program from #14579 now
works correctly.

Test Plan: make test TEST=T14579

Reviewers: simonpj, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, thomie, carter

GHC Trac Issues: #14579

Differential Revision: https://phabricator.haskell.org/D4264

(cherry picked from commit 649e777211fe08432900093002547d7358f92d82)
compiler/hsSyn/HsUtils.hs
testsuite/tests/deriving/should_compile/T14578.stderr
testsuite/tests/deriving/should_compile/T14579.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/all.T