Incorrect redundant import warning for type classes
Given the three files below, the import marked with (!!!) is reported as redundant. Upon deleting it, GHC reports that "has" is not a visible class method of BClass.
This came up in the context of the MFP (#10751 (closed)), with the correspondences Base<->Control.Monad, Extends<->Control.Monad.Fail. We would like to have Control.Monad re-export Control.Monad.Fail.MonadFail without its (clashing) member "fail" for the time being. For future compatibility, some modules should implement MonadFail right now, requiring us to import Control.Monad.Fail explicitly in order to write an instance. Said procedure leads to the described import warning, which breaks the validation script for example.
-- Base.hs module Base (AClass(..), BClass()) where import Extends (BClass()) class AClass a where has :: a
-- Extends.hs module Extends where class BClass b where has :: b
-- UseSite.hs module UseSite where import Base import Extends -- (!!!) data Bar = Bar instance AClass Bar where has = Bar instance BClass Bar where has = Bar
We either get
UseSite.hs:12:5: error: ‘has’ is not a (visible) method of class ‘BClass’
UseSite.hs:4:1: warning: The import of ‘Extends’ is redundant except perhaps to import instances from ‘Extends’ To import instances alone, use: import Extends()