Fix #15637 by using VTA more in GND
authorRyan Scott <ryan.gl.scott@gmail.com>
Mon, 1 Oct 2018 16:00:52 +0000 (12:00 -0400)
committerRyan Scott <ryan.gl.scott@gmail.com>
Mon, 1 Oct 2018 16:00:53 +0000 (12:00 -0400)
commit309438e948359a0ae71ffac4a41ebcd855cf5657
tree254c842685fd4d1b84fd60141e420cac5f033eb8
parent64475db050f25135e30d787ddeaf4e28ff00e1ef
Fix #15637 by using VTA more in GND

Summary:
The code that GND was generating before could crumple over
if it derived an instance for a class with an ambiguous type variable
in the class head, such as the example in #15637. The solution is
straightforward: simply instantiate all variables bound by the class
head explicitly using visible type application, which will nip any
ambiguity in the bud.

Test Plan: make test TEST=T15637

Reviewers: bgamari, simonpj, goldfire

Reviewed By: simonpj

Subscribers: simonpj, rwbarton, carter

GHC Trac Issues: #15637

Differential Revision: https://phabricator.haskell.org/D5148
compiler/typecheck/FamInst.hs
compiler/typecheck/TcGenDeriv.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcValidity.hs
compiler/types/Type.hs
testsuite/tests/deriving/should_compile/T14578.stderr
testsuite/tests/deriving/should_compile/T15637.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/all.T
testsuite/tests/deriving/should_fail/T15073.stderr
testsuite/tests/deriving/should_fail/T4846.stderr