[m-rev.] for review: import instance declarations transitively
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Jul 23 15:43:32 AEST 2002
Estimated hours taken: 0.5
Branches: main
compiler/modules.m:
Put instance declarations in the `.int2' files to avoid
producing `superclass constraints not satisfied' errors
for instance declarations for subclasses defined in the
interface of importing modules.
Without this change, all modules importing the module definining
the instance for the subclass must also import the module
defining the instance for the superclass.
tests/valid/Mmakefile:
tests/valid/transitive_instance.m:
Test case.
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.239
diff -u -u -r1.239 modules.m
--- compiler/modules.m 30 Jun 2002 17:06:33 -0000 1.239
+++ compiler/modules.m 22 Jul 2002 07:48:05 -0000
@@ -5961,6 +5961,7 @@
include_in_short_interface(inst_defn(_, _, _, _, _)).
include_in_short_interface(mode_defn(_, _, _, _, _)).
include_in_short_interface(module_defn(_, _)).
+include_in_short_interface(instance(_, _, _, _, _, _)).
:- pred make_abstract_defn(item, short_interface_kind, item).
:- mode make_abstract_defn(in, in, out) is semidet.
@@ -5984,6 +5985,8 @@
% types only for the `.int3' files.
ShortInterfaceKind = int3
).
+make_abstract_defn(instance(_, _, _, _, _, _) @ Item0, int2, Item) :-
+ make_abstract_instance(Item0, Item).
make_abstract_defn(typeclass(A, B, C, _, E), _,
typeclass(A, B, C, abstract, E)).
Index: tests/valid/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/valid/Mmakefile,v
retrieving revision 1.108
diff -u -u -r1.108 Mmakefile
--- tests/valid/Mmakefile 21 Jul 2002 08:00:54 -0000 1.108
+++ tests/valid/Mmakefile 23 Jul 2002 05:30:27 -0000
@@ -162,6 +162,7 @@
switches.m \
tabled_io.m \
tabled_for_io.m \
+ transitive_instance.m \
tricky_assert2.m \
tricky_ite.m \
two_pragma_c_codes.m \
Index: tests/valid/transitive_instance.m
===================================================================
RCS file: tests/valid/transitive_instance.m
diff -N tests/valid/transitive_instance.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/valid/transitive_instance.m 23 Jul 2002 05:29:47 -0000
@@ -0,0 +1,34 @@
+:- module transitive_instance.
+
+:- interface.
+
+:- type t.
+
+:- implementation.
+
+:- import_module transitive_instance__sub2.
+
+:- type t ---> some [T] c(T) => c2(T).
+
+:- module transitive_instance__sub1.
+
+ :- interface.
+
+ :- typeclass c1(T) where [].
+
+ :- instance c1(int) where [].
+
+:- end_module transitive_instance__sub1.
+
+
+:- module transitive_instance__sub2.
+
+ :- interface.
+
+ :- import_module transitive_instance__sub1.
+
+ :- typeclass c2(T) <= c1(T) where [].
+
+ :- instance c2(int) where [].
+
+:- end_module transitive_instance__sub2.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list