This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Java PR #72
- To: egcs-patches at egcs dot cygnus dot com
- Subject: [PATCH] Java PR #72
- From: Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Wed, 17 Nov 1999 20:07:12 -0800
- Cc: gback at cs dot utah dot edu
I checked in this patch which fixes the PR #72:
http://sourceware.cygnus.com/ml/java-discuss/1999-q4/msg00219.html
./A
Wed Nov 3 15:20:02 MST 1999 Godmar Back <gback@cs.utah.edu>
* typeck.c: (lookup_java_method): search all inherited
interfaces when looking up interface method.
Index: typeck.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/java/typeck.c,v
retrieving revision 1.19
diff -u -p -r1.19 typeck.c
--- typeck.c 1999/10/14 17:13:57 1.19
+++ typeck.c 1999/11/18 03:58:25
@@ -743,13 +743,15 @@ lookup_argument_method (clas, method_nam
(Contrast lookup_argument_method, which ignores return type.) */
tree
-lookup_java_method (clas, method_name, method_signature)
- tree clas, method_name, method_signature;
+lookup_java_method (searched_class, method_name, method_signature)
+ tree searched_class, method_name, method_signature;
{
tree method;
- while (clas != NULL_TREE)
+ tree currently_searched = searched_class;
+
+ while (currently_searched != NULL_TREE)
{
- for (method = TYPE_METHODS (clas);
+ for (method = TYPE_METHODS (currently_searched);
method != NULL_TREE; method = TREE_CHAIN (method))
{
tree method_sig = build_java_signature (TREE_TYPE (method));
@@ -757,7 +759,51 @@ lookup_java_method (clas, method_name, m
&& method_sig == method_signature)
return method;
}
- clas = CLASSTYPE_SUPER (clas);
+ currently_searched = CLASSTYPE_SUPER (currently_searched);
+ }
+
+ /* If this class is an interface class, search its superinterfaces as
+ * well. A superinterface is not an interface's superclass: a
+ * super interface is implemented by the interface.
+ */
+
+ currently_searched = searched_class;
+ if (CLASS_INTERFACE (TYPE_NAME (currently_searched)))
+ {
+ int i;
+ int interface_len =
+ TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (currently_searched)) - 1;
+
+ for (i = interface_len; i > 0; i--)
+ {
+ tree child =
+ TREE_VEC_ELT (TYPE_BINFO_BASETYPES (currently_searched), i);
+ tree iclass = BINFO_TYPE (child);
+
+ /* If the superinterface hasn't been loaded yet, do so now. */
+ if (! CLASS_LOADED_P (iclass))
+ load_class (iclass, 1);
+
+ for (method = TYPE_METHODS (iclass);
+ method != NULL_TREE; method = TREE_CHAIN (method))
+ {
+ tree method_sig = build_java_signature (TREE_TYPE (method));
+
+ if (DECL_NAME (method) == method_name
+ && method_sig == method_signature)
+ return method;
+ }
+
+ /* it could be defined in a supersuperinterface */
+ if (CLASS_INTERFACE (TYPE_NAME (iclass)))
+ {
+ method = lookup_java_method (iclass,
+ method_name,
+ method_signature);
+ if (method != NULL_TREE)
+ return method;
+ }
+ }
}
return NULL_TREE;
}