Fix #15012 with a well-placed use of Any
authorRyan Scott <ryan.gl.scott@gmail.com>
Thu, 19 Apr 2018 16:36:42 +0000 (12:36 -0400)
committerBen Gamari <ben@smart-cactus.org>
Thu, 19 Apr 2018 17:18:14 +0000 (13:18 -0400)
commitb08a6d75e0440f33260bea5319b8c3f871b42f6e
treeeeae0a52bc64aac7a1a9e2d83e25053f0b87e243
parentcac8be611e7e80ed80e24b15faac9e1ac0a07247
Fix #15012 with a well-placed use of Any

Previously, derived `Generic1` instances could have associated `Rep1`
type family instances with unbound variables, such as in the following
example:

```lang=haskell
data T a = MkT (FakeOut a) deriving Generic1
type FakeOut a = Int

==>

instance Generic1 T where
  type Rep1 T = ... (Rec0 (FakeOut a))
```

Yikes! To avoid this, we simply map the last type variable in a
derived `Generic1` instance to `Any`.

Test Plan: make test TEST=T15012

Reviewers: bgamari

Reviewed By: bgamari

Subscribers: simonpj, thomie, carter

GHC Trac Issues: #15012

Differential Revision: https://phabricator.haskell.org/D4602
compiler/typecheck/TcGenGenerics.hs
testsuite/tests/generics/Makefile
testsuite/tests/generics/T15012.hs [new file with mode: 0644]
testsuite/tests/generics/T15012a.hs [new file with mode: 0644]
testsuite/tests/generics/all.T