[commit: ghc] master: Load orphan interfaces before checking if module implements signature (9c9a222)
git at git.haskell.org
git at git.haskell.org
Wed Dec 14 03:01:15 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/9c9a2229fe741c55a8fb8d0c6380ec066a77722b/ghc
>---------------------------------------------------------------
commit 9c9a2229fe741c55a8fb8d0c6380ec066a77722b
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date: Tue Dec 13 18:03:47 2016 -0800
Load orphan interfaces before checking if module implements signature
Summary:
If we didn't load the orphans, we might conclude an instance
is not implemented when it is. See test bkp42.
Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
Test Plan: validate
Reviewers: simonpj, austin, bgamari
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2841
>---------------------------------------------------------------
9c9a2229fe741c55a8fb8d0c6380ec066a77722b
compiler/typecheck/TcBackpack.hs | 5 +++++
testsuite/tests/backpack/should_compile/all.T | 1 +
.../tests/backpack/should_compile/{bkp41.bkp => bkp42.bkp} | 9 ++++++---
testsuite/tests/backpack/should_compile/bkp42.stderr | 14 ++++++++++++++
4 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/compiler/typecheck/TcBackpack.hs b/compiler/typecheck/TcBackpack.hs
index b6623cd..1cf3393 100644
--- a/compiler/typecheck/TcBackpack.hs
+++ b/compiler/typecheck/TcBackpack.hs
@@ -549,6 +549,11 @@ checkImplements impl_mod (IndefModule uid mod_name) = do
(gresFromAvails Nothing (mi_exports impl_iface))
nsubst = mkNameShape (moduleName impl_mod) (mi_exports impl_iface)
+ -- Load all the orphans, so the subsequent 'checkHsigIface' sees
+ -- all the instances it needs to
+ loadModuleInterfaces (text "Loading orphan modules (from implementor of hsig)")
+ (dep_orphs (mi_deps impl_iface))
+
dflags <- getDynFlags
let avails = calculateAvails dflags
impl_iface False{- safe -} False{- boot -}
diff --git a/testsuite/tests/backpack/should_compile/all.T b/testsuite/tests/backpack/should_compile/all.T
index 1f0136f..bb77278 100644
--- a/testsuite/tests/backpack/should_compile/all.T
+++ b/testsuite/tests/backpack/should_compile/all.T
@@ -33,3 +33,4 @@ test('bkp38', normal, backpack_compile, [''])
test('bkp39', normal, backpack_compile, [''])
test('bkp40', normal, backpack_compile, [''])
test('bkp41', normal, backpack_compile, [''])
+test('bkp42', normal, backpack_compile, [''])
diff --git a/testsuite/tests/backpack/should_compile/bkp41.bkp b/testsuite/tests/backpack/should_compile/bkp42.bkp
similarity index 66%
copy from testsuite/tests/backpack/should_compile/bkp41.bkp
copy to testsuite/tests/backpack/should_compile/bkp42.bkp
index e8b5b24..59590f9 100644
--- a/testsuite/tests/backpack/should_compile/bkp41.bkp
+++ b/testsuite/tests/backpack/should_compile/bkp42.bkp
@@ -5,14 +5,17 @@ unit impl where
import A
instance Show T where
show T = "T"
+ module C(module B) where
+ import B
unit sig where
signature B where
- data T = T
+ data T
instance Show T
module App where
import B
- app = print T
+ app :: T -> IO ()
+ app t = print t
unit main where
- dependency sig[B=impl:B]
+ dependency sig[B=impl:C]
diff --git a/testsuite/tests/backpack/should_compile/bkp42.stderr b/testsuite/tests/backpack/should_compile/bkp42.stderr
new file mode 100644
index 0000000..69d8d7c
--- /dev/null
+++ b/testsuite/tests/backpack/should_compile/bkp42.stderr
@@ -0,0 +1,14 @@
+[1 of 3] Processing impl
+ Instantiating impl
+ [1 of 3] Compiling A ( impl/A.hs, bkp42.out/impl/A.o )
+ [2 of 3] Compiling B ( impl/B.hs, bkp42.out/impl/B.o )
+ [3 of 3] Compiling C ( impl/C.hs, bkp42.out/impl/C.o )
+[2 of 3] Processing sig
+ [1 of 2] Compiling B[sig] ( sig/B.hsig, nothing )
+ [2 of 2] Compiling App ( sig/App.hs, nothing )
+[3 of 3] Processing main
+ Instantiating main
+ [1 of 1] Including sig[B=impl:C]
+ Instantiating sig[B=impl:C]
+ [1 of 2] Compiling B[sig] ( sig/B.hsig, bkp42.out/sig/sig-Ko6MwJiRFc509cOdDShPV5/B.o )
+ [2 of 2] Compiling App ( sig/App.hs, bkp42.out/sig/sig-Ko6MwJiRFc509cOdDShPV5/App.o )
More information about the ghc-commits
mailing list