Estimated hours taken: 8
Fix a bug in the module import mechanism -- use_module should
not be transitive. This change is needed for smart recompilation
to avoid needing to check whether the removal of a transitive
import could cause compilation errors -- it never should.
Also fix some bugs in the handling of type class declarations.
compiler/prog_data.m:
Add a `transitively_imported' pseudo-declaration, which
is placed before the items from `.int2' files and `.opt'
files.
Fix the representation of type class bodies.
`:- typeclass foo where [].' declares a typeclass with no
methods. `:- typeclass foo.' declares an abstract typeclass.
The old representation made no distinction between these cases.
compiler/hlds_data.m:
compiler/prog_data.m:
compiler/module_qual.m:
Move the declaration of type type_id from hlds_data.m to prog_data.m.
This avoids a duplicate declaration in module_qual.m.
compiler/modules.m:
Add a `transitively_imported' pseudo-declaration before the
items from `.int2' files.
Remove the bodies of typeclass declarations placed in `.int2'
files -- the methods should not be available unless the module
is explicitly imported.
compiler/module_qual.m:
Items after the `transitively_imported' pseudo-declaration
should not be considered when module qualifying locally
declared items.
compiler/equiv_type.m:
compiler/mercury_to_mercury.m:
compiler/prog_io_typeclass.m:
Handle the change to the representation of typeclass bodies.
compiler/prog_io_typeclass.m:
Check that the arguments of a typeclass declaration
are distinct variables.
compiler/make_hlds.m:
Handle abstract typeclass declarations.
compiler/check_typeclass.m:
Check that all typeclasses have a definition somewhere.
compiler/intermod.m:
Write abstract_exported typeclasses to the `.opt' file.
compiler/add_trail_ops.m:
compiler/context.m:
compiler/llds.m:
compiler/vn_type.m:
Add missing imports.
compiler/magic_util.m:
compiler/ml_type_gen.m:
Remove unnecessary imports.
NEWS:
Note that this change may break existing programs.
compiler/notes/todo.html:
Remove the item relating to this change.
tests/invalid/transitive_import.{m,err_exp}:
Add some tests for uses of transitively imported items.
tests/invalid/transitive_import_class.m:
tests/invalid/transitive_import_class2.m:
tests/invalid/transitive_import_class3.m:
tests/invalid/transitive_import_class.err_exp:
Add a test for use of transitively imported class methods.
tests/invalid/invalid_typeclass.{m,err_exp}:
Add some tests for invalid typeclass declarations.
tests/invalid/Mmakefile:
Add the new tests.