• Simon Peyton Jones's avatar
    Deal correctly with unused imports for 'coerce' · 23b80ac4
    Simon Peyton Jones authored
    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
all.T 19.4 KB