Axe initIfaceTc, tie the knot through HPT (or if_rec_types).
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Sun, 19 Jun 2016 21:28:55 +0000 (14:28 -0700)
committerEdward Z. Yang <ezyang@cs.stanford.edu>
Sun, 21 Aug 2016 07:53:21 +0000 (00:53 -0700)
commite907e1f12f4dedc0ec13c7a501c8810bcfc03583
tree0cd06a1eb0cd56a449c92f5ba9f8f5cce769dc61
parent896d216d47cf185d071e0388acbbaef10abada88
Axe initIfaceTc, tie the knot through HPT (or if_rec_types).

Summary:
initIfaceTc was originally used to make sure when we typecheck
an interface, it can find the TyThings for things it itself
defined.  However, in the case of retypecheckLoop, this wasn't
necessary because we ALREADY tied the knot through the HPT.

This commit removes initIfaceTc, instead relying on the HPT
to tie the knot.  genModDetails' caller needed to be modified
to tie the knot, but there are not that many call-sites of
typecheckIface so the change is quite reasonable.

We also introduce a new 'initIfaceLoad', which does
NOT set up 'if_rec_types'.  It's used when we're
typechecking old, up-to-date interfaces in, since we're
never going to update the type environment.

The full details are in Note [Knot-tying typecheckIface].
Displeasingly, we need a special case to handle DFuns in
the case of tcHiBootIface, see
Note [DFun knot-tying special case] for the gory details.

I also added another test which tickles a bug in a buggy
version of this patch (see "Why the seq?")

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2349
12 files changed:
compiler/iface/TcIface.hs
compiler/main/HscMain.hs
compiler/main/HscTypes.hs
compiler/typecheck/TcRnDriver.hs
compiler/typecheck/TcRnMonad.hs
compiler/typecheck/TcRnTypes.hs
testsuite/driver/extra_files.py
testsuite/tests/typecheck/should_compile/Makefile
testsuite/tests/typecheck/should_compile/Tc266.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/Tc266.hs-boot [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/Tc266a.hs [new file with mode: 0644]
testsuite/tests/typecheck/should_compile/all.T