Deal correctly with unused imports for 'coerce'
authorSimon Peyton Jones <simonpj@microsoft.com>
Tue, 28 Jun 2016 11:13:13 +0000 (12:13 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Tue, 28 Jun 2016 12:41:41 +0000 (13:41 +0100)
commit23b80ac41cc945cea0fc6ff9ade6b4be8aa81b7f
tree37f5a893bd97a859bca72f28816dc65f179f1156
parentaf21e38855f7d517774542b360178b05045ecb08
Deal correctly with unused imports for 'coerce'

We only do newtype unwrapping for Coercible constraints if
the newtype's data constructor is in scope.  We were trying to
record the fact that the data constructor was thereby 'used', so
that an import statement would not be flagged as unnecsssary
(by -Wunused-imports).

But the code was simply wrong. It was wrong because it assumed
that only one level of unwrapping happened, whereas
tcTopNormaliseNewTypeTF_maybe actually unwraps multiple layers.
So we need to return a /list/ of data constructors that are used.

This entailed a bit of refactoring, as usual.

Fixes Trac #12067
compiler/typecheck/FamInst.hs
compiler/typecheck/TcCanonical.hs
compiler/typecheck/TcSMonad.hs
compiler/types/Coercion.hs
compiler/types/FamInstEnv.hs
compiler/types/TyCon.hs
testsuite/tests/typecheck/should_compile/T12067.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/T12067a.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/all.T