diff options
| author | Edward Z. Yang <ezyang@cs.stanford.edu> | 2017-02-12 04:28:38 -0800 |
|---|---|---|
| committer | Edward Z. Yang <ezyang@cs.stanford.edu> | 2017-02-17 13:46:28 -0800 |
| commit | 22dba98f2b22141d8238d7e7a42141495945f1cf (patch) | |
| tree | 6d69dd6337e36d1076dfcaa57bc1c311d2373802 | |
| parent | ca543154bbf0ec36ee2654050ee67a467420449f (diff) | |
| download | haskell-22dba98f2b22141d8238d7e7a42141495945f1cf.tar.gz | |
Fix recompilation tracking on signatures.
Summary:
Previously we weren't tracking these dependencies at all,
because we couldn't "find" the interface for {A.H}. Now
we've associated hole names to the correct module identity
so we will pick them up.
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate
Reviewers: bgamari, austin
Subscribers: thomie, snowleopard
Differential Revision: https://phabricator.haskell.org/D3131
| -rw-r--r-- | compiler/deSugar/DsUsage.hs | 15 | ||||
| -rw-r--r-- | compiler/typecheck/TcRnTypes.hs | 4 | ||||
| -rw-r--r-- | testsuite/driver/extra_files.py | 1 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/.gitignore | 1 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/A.hsig.in1 | 3 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/A.hsig.in2 | 2 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/M.hs | 4 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/Makefile | 23 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/Setup.hs | 2 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/all.T | 9 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/bkpcabal05.cabal | 12 | ||||
| -rw-r--r-- | testsuite/tests/backpack/cabal/bkpcabal05/bkpcabal05.stderr | 5 |
12 files changed, 76 insertions, 5 deletions
diff --git a/compiler/deSugar/DsUsage.hs b/compiler/deSugar/DsUsage.hs index 665f2933bb..da29ac0e6a 100644 --- a/compiler/deSugar/DsUsage.hs +++ b/compiler/deSugar/DsUsage.hs @@ -119,11 +119,16 @@ mk_mod_usage_info pit hsc_env this_mod direct_imports used_names Nothing -> ASSERT2( isSystemName name, ppr name ) mv_map -- See Note [Internal used_names] - Just mod -> -- This lambda function is really just a - -- specialised (++); originally came about to - -- avoid quadratic behaviour (trac #2680) - extendModuleEnvWith (\_ xs -> occ:xs) mv_map mod [occ] - where occ = nameOccName name + Just mod -> + -- See Note [Identity versus semantic module] + let mod' = if isHoleModule mod + then mkModule this_pkg (moduleName mod) + else mod + -- This lambda function is really just a + -- specialised (++); originally came about to + -- avoid quadratic behaviour (trac #2680) + in extendModuleEnvWith (\_ xs -> occ:xs) mv_map mod' [occ] + where occ = nameOccName name -- We want to create a Usage for a home module if -- a) we used something from it; has something in used_names diff --git a/compiler/typecheck/TcRnTypes.hs b/compiler/typecheck/TcRnTypes.hs index 6b9db4889a..f0ca574cd4 100644 --- a/compiler/typecheck/TcRnTypes.hs +++ b/compiler/typecheck/TcRnTypes.hs @@ -475,6 +475,10 @@ data FrontendResult -- in the home library we are compiling. (See LoadIface.) -- Similarly, in RnNames we check for self-imports using -- identity modules, to allow signatures to import their implementor. +-- +-- - For recompilation avoidance, you want the identity module, +-- since that will actually say the specific interface you +-- want to track (and recompile if it changes) -- | 'TcGblEnv' describes the top-level of the module at the diff --git a/testsuite/driver/extra_files.py b/testsuite/driver/extra_files.py index 82d2c997f9..28e9348a28 100644 --- a/testsuite/driver/extra_files.py +++ b/testsuite/driver/extra_files.py @@ -162,6 +162,7 @@ extra_src_files = { 'bkpcabal02': ['p', 'q', 'bkpcabal02.cabal', 'Setup.hs'], 'bkpcabal03': ['asig1', 'asig2', 'bkpcabal03.cabal.in1', 'bkpcabal03.cabal.in2', 'Setup.hs', 'Mod.hs'], 'bkpcabal04': ['p','q','bkpcabal04.cabal.in1','bkpcabal04.cabal.in2','Setup.hs'], + 'bkpcabal05': ['bkpcabal05.cabal','A.hsig.in1','A.hsig.in2','M.hs','Setup.hs'], 'break001': ['../Test2.hs'], 'break002': ['../Test2.hs'], 'break003': ['../Test3.hs'], diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/.gitignore b/testsuite/tests/backpack/cabal/bkpcabal05/.gitignore new file mode 100644 index 0000000000..d73b31a94a --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/.gitignore @@ -0,0 +1 @@ +A.hsig diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/A.hsig.in1 b/testsuite/tests/backpack/cabal/bkpcabal05/A.hsig.in1 new file mode 100644 index 0000000000..7f470647e6 --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/A.hsig.in1 @@ -0,0 +1,3 @@ +signature A where +data T +instance Show T diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/A.hsig.in2 b/testsuite/tests/backpack/cabal/bkpcabal05/A.hsig.in2 new file mode 100644 index 0000000000..19a83e4100 --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/A.hsig.in2 @@ -0,0 +1,2 @@ +signature A where +data T diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/M.hs b/testsuite/tests/backpack/cabal/bkpcabal05/M.hs new file mode 100644 index 0000000000..7f4f64aede --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/M.hs @@ -0,0 +1,4 @@ +module M where +import A +f :: T -> String +f = show diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/Makefile b/testsuite/tests/backpack/cabal/bkpcabal05/Makefile new file mode 100644 index 0000000000..d4c116bf32 --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/Makefile @@ -0,0 +1,23 @@ +TOP=../../../.. +include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/test.mk + +SETUP='$(PWD)/Setup' -v0 +CONFIGURE=$(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)' --package-db='$(PWD)/tmp.d' --prefix='$(PWD)/inst' + +bkpcabal05: clean + $(MAKE) -s --no-print-directory clean + '$(GHC_PKG)' init tmp.d + '$(TEST_HC)' -v0 --make Setup + $(CONFIGURE) + cp A.hsig.in1 A.hsig + # typecheck + $(SETUP) build + cp A.hsig.in2 A.hsig + ! $(SETUP) build +ifneq "$(CLEANUP)" "" + $(MAKE) -s --no-print-directory clean +endif + +clean : + $(RM) -rf tmp.d inst dist Setup$(exeext) A.hsig diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/Setup.hs b/testsuite/tests/backpack/cabal/bkpcabal05/Setup.hs new file mode 100644 index 0000000000..9a994af677 --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/Setup.hs @@ -0,0 +1,2 @@ +import Distribution.Simple +main = defaultMain diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/all.T b/testsuite/tests/backpack/cabal/bkpcabal05/all.T new file mode 100644 index 0000000000..ab75dba8f5 --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/all.T @@ -0,0 +1,9 @@ +if config.cleanup: + cleanup = 'CLEANUP=1' +else: + cleanup = 'CLEANUP=0' + +test('bkpcabal05', + normal, + run_command, + ['$MAKE -s --no-print-directory bkpcabal05 ' + cleanup]) diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/bkpcabal05.cabal b/testsuite/tests/backpack/cabal/bkpcabal05/bkpcabal05.cabal new file mode 100644 index 0000000000..47e78a4b74 --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/bkpcabal05.cabal @@ -0,0 +1,12 @@ +name: bkpcabal05 +version: 0.1.0.0 +license: BSD3 +author: Edward Z. Yang +maintainer: ezyang@cs.stanford.edu +build-type: Simple +cabal-version: >=1.25 + +library + signatures: A + exposed-modules: M + build-depends: base diff --git a/testsuite/tests/backpack/cabal/bkpcabal05/bkpcabal05.stderr b/testsuite/tests/backpack/cabal/bkpcabal05/bkpcabal05.stderr new file mode 100644 index 0000000000..6f0879605c --- /dev/null +++ b/testsuite/tests/backpack/cabal/bkpcabal05/bkpcabal05.stderr @@ -0,0 +1,5 @@ + +M.hs:4:5: error: + • No instance for (Show T) arising from a use of ‘show’ + • In the expression: show + In an equation for ‘f’: f = show |
