[commit: ghc] master: Deal correctly with unused imports for 'coerce' (23b80ac)

git at git.haskell.org git at git.haskell.org
Tue Jun 28 12:37:50 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/23b80ac41cc945cea0fc6ff9ade6b4be8aa81b7f/ghc

>---------------------------------------------------------------

commit 23b80ac41cc945cea0fc6ff9ade6b4be8aa81b7f
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Tue Jun 28 12:13:13 2016 +0100

    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


>---------------------------------------------------------------

23b80ac41cc945cea0fc6ff9ade6b4be8aa81b7f
 compiler/typecheck/FamInst.hs                      | 36 ++++++----
 compiler/typecheck/TcCanonical.hs                  | 22 +++---
 compiler/typecheck/TcSMonad.hs                     |  8 +--
 compiler/types/Coercion.hs                         | 80 ++++++++++++----------
 compiler/types/FamInstEnv.hs                       |  2 +-
 compiler/types/TyCon.hs                            |  5 ++
 testsuite/tests/typecheck/should_compile/T12067.hs |  9 +++
 .../tests/typecheck/should_compile/T12067a.hs      |  6 ++
 testsuite/tests/typecheck/should_compile/all.T     |  2 +
 9 files changed, 102 insertions(+), 68 deletions(-)

Diff suppressed because of size. To see it, use:

    git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc 23b80ac41cc945cea0fc6ff9ade6b4be8aa81b7f


More information about the ghc-commits mailing list