Fix scoping of TyCon binders in TcTyClsDecls
This patch fixes #17566 by refactoring the way we decide the final identity of the tyvars in the TyCons of a possibly-recursive nest of type and class decls, possibly with associated types. It's all laid out in Note [Swizzling the tyvars before generaliseTcTyCon] Main changes: * We have to generalise each decl (with its associated types) all at once: TcTyClsDecls.generaliseTyClDecl * The main new work is done in TcTyClsDecls.swizzleTcTyConBndrs * The mysterious TcHsSyn.zonkRecTyVarBndrs dies altogether Other smaller things: * A little refactoring, moving bindTyClTyVars from tcTyClDecl1 to tcDataDefn, tcSynRhs, etc. Clearer, reduces the number of parameters * Reduce the amount of swizzling required. Specifically, bindExplicitTKBndrs_Q_Tv doesn't need to clone a new Name for the TyVarTv, and not cloning means that in the vasly common case, swizzleTyConBndrs is a no-op In detail: Rename newTyVarTyVar --> cloneTyVarTyVar Add newTyVarTyTyVar that doesn't clone Use the non-cloning newTyVarTyVar in bindExplicitTKBndrs_Q_Tv Rename newFlexiKindedTyVarTyVar --> cloneFlexiKindedTyVarTyVar * Define new utility function and use it HsDecls.familyDeclName :: FamilyDecl (GhcPass p) -> IdP (GhcPass p) Updates haddock submodule.
Showing
- compiler/GHC/Hs/Decls.hs 20 additions, 5 deletionscompiler/GHC/Hs/Decls.hs
- compiler/deSugar/ExtractDocs.hs 1 addition, 3 deletionscompiler/deSugar/ExtractDocs.hs
- compiler/typecheck/TcHsSyn.hs 16 additions, 34 deletionscompiler/typecheck/TcHsSyn.hs
- compiler/typecheck/TcHsType.hs 162 additions, 107 deletionscompiler/typecheck/TcHsType.hs
- compiler/typecheck/TcMType.hs 18 additions, 32 deletionscompiler/typecheck/TcMType.hs
- compiler/typecheck/TcTyClsDecls.hs 333 additions, 113 deletionscompiler/typecheck/TcTyClsDecls.hs
- testsuite/tests/polykinds/T11203.stderr 2 additions, 2 deletionstestsuite/tests/polykinds/T11203.stderr
- testsuite/tests/polykinds/T11821a.stderr 2 additions, 2 deletionstestsuite/tests/polykinds/T11821a.stderr
- testsuite/tests/typecheck/should_compile/Makefile 5 additions, 0 deletionstestsuite/tests/typecheck/should_compile/Makefile
- testsuite/tests/typecheck/should_compile/T17566.hs 20 additions, 0 deletionstestsuite/tests/typecheck/should_compile/T17566.hs
- testsuite/tests/typecheck/should_compile/T17566a.hs 15 additions, 0 deletionstestsuite/tests/typecheck/should_compile/T17566a.hs
- testsuite/tests/typecheck/should_compile/all.T 1 addition, 0 deletionstestsuite/tests/typecheck/should_compile/all.T
- testsuite/tests/typecheck/should_fail/T17566b.hs 7 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T17566b.hs
- testsuite/tests/typecheck/should_fail/T17566b.stderr 4 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T17566b.stderr
- testsuite/tests/typecheck/should_fail/T17566c.hs 11 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T17566c.hs
- testsuite/tests/typecheck/should_fail/T17566c.stderr 6 additions, 0 deletionstestsuite/tests/typecheck/should_fail/T17566c.stderr
- testsuite/tests/typecheck/should_fail/all.T 2 additions, 0 deletionstestsuite/tests/typecheck/should_fail/all.T
- utils/haddock 1 addition, 1 deletionutils/haddock
Loading
Please register or sign in to comment