Fix egregious duplication of vars in RnTypes

Authored by RyanGlScott on Sep 4 2017, 7:00 AM.


Fix egregious duplication of vars in RnTypes

RnTypes contains a fairly intricate algorithm to extract
the kind and type variables of an HsType. This algorithm carefully
maintains the separation between type variables and kind variables
so that the difference between -XPolyKinds and -XTypeInType can
be respected.

But after doing all this, rmDupsInRdrTyVars stupidly just
concatenated the lists of type and kind variables at the end. If a
variable were used as both a type and a kind, the algorithm would
produce *both*! This led to all kinds of problems, including Trac #13988.

This is mostly Richard Eisenberg's patch. The only original
contribution I made was adapting call sites of rnImplicitBndrs to
work with the new definition of rmDupsInRdrTyVars. That is,
rnImplicitBndrs checks for variables that are illegally used in
both type and kind positions without using -XTypeInType, but in
order to check this, one cannot have filtered duplicate variables out
before passing them to rnImplicitBndrs. To accommodate for this, I
needed to concoct variations on the existing extract- functions in
RnTypes which do not remove duplicates, and use those near
rnImplicitBndrs call sites.

test case: ghci/scripts/T13988

Test Plan: make test TEST=T13988

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: goldfire, simonpj

Subscribers: rwbarton, thomie

GHC Trac Issues: Trac #13988

Differential Revision: