Fix binder visiblity for default methods
authorSimon Peyton Jones <simonpj@microsoft.com>
Wed, 26 Jul 2017 07:51:47 +0000 (08:51 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Wed, 26 Jul 2017 11:33:42 +0000 (12:33 +0100)
commit75bf11c037d9e82f95ac9779bfd2b1432835bd76
tree896e4585202593c1721180ee8f47ae3fb75a0500
parent746ab0b4a2f97d9f2a97fc28431e5bdfbc10b8cf
Fix binder visiblity for default methods

Trac #13998 showed that default methods were getting bogus tyvar
binder visiblity info; and that it matters in the code genreated
by the default-method fill-in mechanism

* The actual fix: in TcTyDecls.mkDefaultMethodType, make TyVarBinders
  with the right visibility info by getting TyConBinders from the
  class TyCon.  (Previously we made up visiblity info, but that
  caused #13998.)

* Define TyCon.tyConTyVarBinders :: [TyConBinder] -> [TyVarBinder]
  which can build correct forall binders for
    a) default methods (Trac #13998)
    b) data constructors
  This was originally BuildTyCl.mkDataConUnivTyVarBinders

* Move mkTyVarBinder, mkTyVarBinders from Type to Var
13 files changed:
compiler/basicTypes/Var.hs
compiler/iface/BuildTyCl.hs
compiler/iface/TcIface.hs
compiler/typecheck/TcPatSyn.hs
compiler/typecheck/TcTyClsDecls.hs
compiler/typecheck/TcTyDecls.hs
compiler/typecheck/TcType.hs
compiler/types/Class.hs
compiler/types/TyCoRep.hs
compiler/types/TyCon.hs
compiler/types/Type.hs
testsuite/tests/deriving/should_compile/T13998.hs [new file with mode: 0644]
testsuite/tests/deriving/should_compile/all.T