[cvs-nhc98] Fix an obscure bug with transitive import/export of instan

Malcolm Wallace malcolm@sparud.net
Wed, 22 Jan 2003 17:58:59 +0100 (CET)


malcolm: Wed Jan 22 17:58:58 CET 2003

Update of /usr/src/master/nhc/src/compiler98
In directory hinken:/tmp/cvs-serv6727

Modified Files:
	Export.hs Info.hs 
Log Message:
Fix an obscure bug with transitive import/export of instances through
several modules.  The fault was this:
    module W:  defines class C, instance C T1, exports C
    module X:  imports W, uses class C, does not explicitly export C or T1
    module Y:  imports X, re-exports X
    module Z:  defines a function that implicitly uses instance C T1
The compiler complained that no such instance exists, even though it does.
The interface file for Y was failing to record the instance C T1.

Now, the interface file for X /does/ record the instance C T1,
even though neither the type nor the class are explicitly exported,
and this is correct.  However, because the class C is mentioned only
`implicitly' (i.e. non-exported) in X's interface, Y did not import
C from X, and did not re-export it either, hence deciding that none
of its instances were relevant.

The fix is to export all the instances attached to an "InfoUsedClass"
(i.e. one found in passing in an interface file but not imported)
in addition to the instances attached to an "InfoClass" (i.e. classes
that are really imported).