Commit 9c9a2229 authored by Edward Z. Yang's avatar Edward Z. Yang

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: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>

Test Plan: validate

Reviewers: simonpj, austin, bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2841
parent 8ec864d0
......@@ -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 -}
......
......@@ -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, [''])
unit impl where
module A where
data T = T
module B(module A, module B) 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
instance Show T
module App where
import B
app :: T -> IO ()
app t = print t
unit main where
dependency sig[B=impl:C]
[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 )
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment