Fix DeriveGeneric for types with same OccName (#10487)
authorÖmer Sinan Ağacan <omeragacan@gmail.com>
Thu, 24 Sep 2015 07:51:19 +0000 (00:51 -0700)
committerEdward Z. Yang <ezyang@cs.stanford.edu>
Thu, 24 Sep 2015 07:52:14 +0000 (00:52 -0700)
commitb08a533dc87423a75bce037eb403d7828d3330d3
tree0c899fe660bf73c8f31f71eecae1ec0d6280aea6
parent2440e3c6b479ac532e2660374a78c8482e903bed
Fix DeriveGeneric for types with same OccName (#10487)

Summary:
DeriveGeneric generates some data types (for data type constructors and for
selectors of those constructors) and instances for those types. This patch
changes name generation for these new types to make it working with data types
with same names imported from different modules and with data types with same
names imported from same modules(using module imports).

Bonus content:

- Some refactoring in `TcGenGenerics.metaTyConsToDerivStuff` to remove some
  redundant partial function applications and to remove a duplicated function.
- Remove some unused names from `OccName`. (those were used for an old
  implementation of `DeriveGeneric`)

Reviewers: kosmikus, simonpj, dreixel, ezyang, bgamari, austin

Reviewed By: bgamari, austin

Subscribers: ezyang, thomie

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

GHC Trac Issues: #10487
compiler/basicTypes/OccName.hs
compiler/typecheck/TcDeriv.hs
compiler/typecheck/TcEnv.hs
compiler/typecheck/TcGenGenerics.hs
testsuite/tests/deriving/should_compile/T10487.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/T10487_M.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/all.T
testsuite/tests/generics/GenDerivOutput.stderr
testsuite/tests/generics/GenDerivOutput1_0.stderr
testsuite/tests/generics/GenDerivOutput1_1.stderr