Fix #13214 by correctly setting up dep_orphs for signatures.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Sun, 12 Feb 2017 00:20:36 +0000 (19:20 -0500)
committerBen Gamari <ben@smart-cactus.org>
Sun, 12 Feb 2017 00:20:43 +0000 (19:20 -0500)
commit26eaa7ecde288b9dc123f3c120e70b2cf18b4e4a
treed6e065354ec986675b637cfcf6b558b518f675cb
parenta1980ecb5626ec85fc14fbd217e2d16c7d50a120
Fix #13214 by correctly setting up dep_orphs for signatures.

Prior to this, I hadn't thought about orphan handling at all.
This commit implements the semantics that if a signature
(transitively) imports an orphan instance, that instance
is considered in scope no matter what the implementing module
is.  (As it turns out, this is the semantics that falls out
when orphans are recorded transitively.)

This patch fixes a few bugs:

1. Put semantic modules in dep_orphs rather than identity
   modules.
2. Don't put the implementing module in dep_orphs when
   merging signatures (this is a silly bug that happened
   because we were reusing calculateAvails, which is
   designed for imports. It mostly works for signature
   merging, except this case.)
3. When renaming a signature, blast in the orphans of the
   implementing module inside Dependencies.

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

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3095
12 files changed:
compiler/backpack/RnModIface.hs
compiler/rename/RnNames.hs
compiler/typecheck/TcBackpack.hs
docs/users_guide/separate_compilation.rst
testsuite/tests/backpack/should_compile/T13214.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_compile/T13214.stderr [new file with mode: 0644]
testsuite/tests/backpack/should_compile/all.T
testsuite/tests/backpack/should_compile/bkp51.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_compile/bkp51.stderr [new file with mode: 0644]
testsuite/tests/backpack/should_fail/all.T
testsuite/tests/backpack/should_fail/bkpfail43.bkp [new file with mode: 0644]
testsuite/tests/backpack/should_fail/bkpfail43.stderr [new file with mode: 0644]