Filter orphan rules based on imports, fixes #10294 and #10420.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Wed, 3 Jun 2015 21:33:05 +0000 (14:33 -0700)
committerEdward Z. Yang <ezyang@cs.stanford.edu>
Sat, 20 Jun 2015 22:13:42 +0000 (15:13 -0700)
commit0cb1f5cf26fae946ca745abc5e302e62a8f66feb
tree07744de6d51cea9bde926d3ea88c1fda2b138974
parent85d539754ac07286ef5fed714ad42451bd5a1d28
Filter orphan rules based on imports, fixes #10294 and #10420.

Summary:
If we have an orphan rule in our database, don't apply it
unless the defining module is transitively imported by the
module we are processing.  We do this by defining a new RuleEnv
data type which includes both the RuleBase as well as the set
of visible orphan modules, and threading this through the
relevant environments (CoreReader, RuleCheckEnv and ScEnv).

This is analogous to the instances fix we applied in #2182
4c834fdddf4d44d12039da4d6a2c63a660975b95, but done for RULES.
An important knock-on effect is that we can remove some buggy
code in LoadInterface which tried to avoid loading interfaces
that were loaded by plugins (which sometimes caused instances
and rules to NEVER become visible).

One note about tests: I renamed the old plugins07 test to T10420
and replaced plugins07 with a test to ensure that a plugin
import did not cause new rules to be loaded in.

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

Reviewers: simonpj, austin, goldfire

Subscribers: bgamari, thomie

Differential Revision: https://phabricator.haskell.org/D950

GHC Trac Issues: #10420
32 files changed:
compiler/coreSyn/CoreFVs.hs
compiler/coreSyn/CoreLint.hs
compiler/coreSyn/CoreSyn.hs
compiler/deSugar/Desugar.hs
compiler/deSugar/DsBinds.hs
compiler/iface/LoadIface.hs
compiler/iface/MkIface.hs
compiler/iface/TcIface.hs
compiler/simplCore/CoreMonad.hs
compiler/simplCore/SimplCore.hs
compiler/simplCore/SimplMonad.hs
compiler/specialise/Rules.hs
compiler/specialise/SpecConstr.hs
compiler/specialise/Specialise.hs
compiler/types/InstEnv.hs
testsuite/.gitignore
testsuite/tests/plugins/Makefile
testsuite/tests/plugins/T10294.hs [new file with mode: 0644]
testsuite/tests/plugins/T10294.stderr [new file with mode: 0644]
testsuite/tests/plugins/T10294a.hs [new file with mode: 0644]
testsuite/tests/plugins/T10420.hs [new file with mode: 0644]
testsuite/tests/plugins/T10420.stdout [new file with mode: 0644]
testsuite/tests/plugins/T10420a.hs [moved from testsuite/tests/plugins/Plugins07a.hs with 66% similarity]
testsuite/tests/plugins/all.T
testsuite/tests/plugins/annotation-plugin/LICENSE [new file with mode: 0644]
testsuite/tests/plugins/annotation-plugin/Makefile [new file with mode: 0644]
testsuite/tests/plugins/annotation-plugin/SayAnnNames.hs [new file with mode: 0644]
testsuite/tests/plugins/annotation-plugin/Setup.hs [new file with mode: 0644]
testsuite/tests/plugins/annotation-plugin/annotation-plugin.cabal [new file with mode: 0644]
testsuite/tests/plugins/plugins07.hs
testsuite/tests/plugins/plugins07.stdout
testsuite/tests/simplCore/should_compile/T8848.stderr